/**
 * @file hv_comm_shell_debug_cmd.c
 * @brief shell-debug c file.
 *
 * @author HiView SoC Software Team
 * @version 1.0.0
 * @date 2023-02-14
 * @copyright Copyright(c),2022-8, Hiview Software. All rights reserved.
 * @par History:
 * <table>
 * <tr><th>Author                        <th>Date            <th>Change Description
 * <tr><td>HiView SoC Software Team      <td>2023-02-14      <td>init
 * </table>
 */

#include <string.h>
#include "hv_comm_Log.h"
#include "hv_comm_shell_hvconfig.h"
#include "hv_comm_DataType.h"
#include "hv_comm_Event.h"
#include "hv_comm_Assert.h"
#ifdef HV_CONFIG_CHIP_HT7315
#include "hv_comm_MemParser.h"
#endif
#include "hv_comm_Utilities.h"
#include "hv_vos_Comm.h"
#include "hv_mw_Factory.h"
#include "hv_mw_Video.h"
#include "hv_mw_Audio.h"
#include "hv_mw_SystemManager.h"
#include "hv_mw_Channel_Manager.h"
#include "hv_mw_DynamicColorWin.h"
#include "hv_mw_InputPortManager.h"
#include "hv_mw_PanelManager.h"
#include "hv_mw_PowerManager.h"
#include "hv_mw_PQ.h"
#include "hv_mw_Bcon.h"
#include "hv_mw_Video_TimingCheck.h"
#include "hv_drv_Mprt.h"
#include "hv_drv_Dma.h"
#include "hv_drv_Bcon.h"
#include "hv_drv_Uart.h"
#include "hv_drv_PLL.h"
#include "hv_drv_Audio.h"
#include "hv_drv_EdpTxTraining.h"
#include "hv_cal_Audio.h"
#include "hv_cal_Dma.h"
#include "hv_cal_I2c.h"
#include "hv_cal_MI2c.h"
#include "hv_drv_I2c.h"
#include "hv_drv_Flash.h"
#include "hv_cal_Dprx.h"
#include "hv_cal_HdmiRx.h"
#include "hv_cal_HdmiInc.h"
#include "hv_chip_Config.h"

#include "hv_cal_DpuMainScaler.h"
#include "hv_cal_DpuCprConfig.h"
#ifdef CONFIG_USER_DOUBLE_CHANNEL_ON
#include "hv_cal_DpuSubScaler.h"
#endif

#include "PanelConfig.h"
#include "hv_drv_Gpio.h"
#include "hv_app_PQ.h"
#include "hv_drv_Led.h"
#include "hv_cal_Tlc5971.h"
#include "hv_drv_Tlc5971.h"
#include "hv_drv_HY8603.h"
#include "hv_mw_Led.h"

extern const char* sColorFormatType[];
extern const char* sColorDepthType[];
extern char* g_strDataPathMode[];
/*防止debug模式下编译优化把shell_debug_cmd.c 优化掉*/
UINT32 g_uiShellDebugForTest = 0;

static Status SendNotifyMessageToSystemTask(SettingParamId enParamId, UINT32 uiValue)
{
    SystemEvent stSystemEvent = {0};
    HV_VOS_QUEUE_S* xSystembQueue = Hv_Mw_System_GetSystemQueue();
    HV_ASSERT_VALID_PTR(xSystembQueue);
    stSystemEvent.enEventType = SYSTEM_REV_EVENT_TYPE_OSD_SETTING;
    stSystemEvent.usEventId = enParamId;
    stSystemEvent.uiValue = uiValue;
    HV_ASSERT_TRUE(Hv_Vos_QueueSend(xSystembQueue, (void *)&stSystemEvent));
    return HV_SUCCESS;
}

const char* s_strTimingMode[] =
{
    "DIS_TIMING_MODE_FRAMESYNC",
    "DIS_TIMING_MODE_FREE_RUN",
    "DIS_TIMING_MODE_TCON",
    "DIS_TIMING_MODE_FREE_RUN_MODE1",
};
const char* s_strDataPathMode[] =
{
    "DATA_PATH_MODE_FRAMESYNC",
    "DATA_PATH_MODE_THROUGH_COLORFORMAT_RX",
    "DATA_PATH_MODE_COMPRESS_COLORFORMAT_RX",
    "DATA_PATH_MODE_THROUGH_COLORFORMAT_YUV444",
    "DATA_PATH_MODE_THROUGH_COLORFORMAT_YUV422",
    "DATA_PATH_MODE_THROUGH_COLORFORMAT_YUV420",
    "DATA_PATH_MODE_COMPRESS_COLORFORMAT_YUV444",
    "DATA_PATH_MODE_COMPRESS_COLORFORMAT_YUV422",
    "DATA_PATH_MODE_COMPRESS_RATIO_3_COLORFORMAT_YUV444",
    "DATA_PATH_MODE_COMPRESS_RATIO_3_COLORFORMAT_YUV422",
};

char* GetErrorCode(USHORT16 usErrorCode)
{
    switch (usErrorCode)
    {
        case ERROR_RX_TIMING_UNSTABLE:
        {
            return "ERROR_RX_TIMING_UNSTABLE";
        }
        case ERROR_RX_TIMING_FREQ_OUT_OF_RANGE:
        {
            return "ERROR_RX_TIMING_FREQ_OUT_OF_RANGE";
        }
        case ERROR_RX_TIMING_COLOR_DEPTH_NOT_SUPPORT:
        {
            return "ERROR_RX_TIMING_COLOR_DEPTH_NOT_SUPPORT";
        }
        case ERROR_RX_NO_SIGNAL:
        {
            return "ERROR_RX_NO_SIGNAL";
        }
        case ERROR_RX_TIMING_UNSUPPORT:
        {
            return "ERROR_RX_TIMING_UNSUPPORT";
        }
        default:
        {
            break;
        }
    }
    return "unknown";
}

/***************************************************************************************************/
/*************************************DPU part start ***********************************************/
/***************************************************************************************************/
int Hv_Shell_ShowDpuConfig(int argc, char* argv[])
{
    HV_R32_DECL_VAR();
    const ChannelManager* pstChannelManager = Hv_Mw_Channel_GetManager();
    HV_LOG_RAW("@@@@@@@@@@@@@@@@@@@@@@@@Main Channel begin@@@@@@@@@@@@@@@@@@@@@@@@");
    HV_LOG_RAW("Current SearchPort Errorcode = %s", GetErrorCode(pstChannelManager->astChannelData[0].uiErrorCode));
    DisplayTimingMode enTimingMode = pstChannelManager->astChannelData[0].stVideoConfigParams.enTimingMode;
    HV_LOG_RAW("Current timing Mode = %s", s_strTimingMode[enTimingMode]);
    DisplayDataPathMode enDataPathMode = pstChannelManager->astChannelData[0].stVideoConfigParams.enDataPathMode;
    HV_LOG_RAW("Current DisplayDataPathMode = %s", s_strDataPathMode[enDataPathMode]);
    HV_LOG_RAW("reg_00_ca_vg_c02_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_24, reg_00_ca_vg_c02_func_clk_en));
    HV_LOG_RAW("reg_00_420_422_en = %u", HV_R32_FIELD(DISP_TOP_C420_422_00_00, reg_00_420_422_en));
    HV_LOG_RAW("reg_00_ca_vg_yuv422to444_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_28, reg_00_ca_vg_yuv422to444_func_clk_en));
    HV_LOG_RAW("reg_00_ca_vg_pair_mapping_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_24, reg_00_ca_vg_pair_mapping_en));
    HV_LOG_RAW("reg_00_ca_vg_cs1_convert_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_30, reg_00_ca_vg_cs1_convert_func_clk_en));
    HV_LOG_RAW("reg_00_ca_vg_csc1_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_30, reg_00_ca_vg_csc1_en));
    HV_LOG_RAW("reg_00_ca_vg_hdr_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_50, reg_00_ca_vg_hdr_func_clk_en));
    HV_LOG_RAW("reg_00_ct_ldg_hdr_passthrough = %u", HV_R32_FIELD(DISP_TOP_LDG_HDR_REG_00_00, reg_00_ct_ldg_hdr_passthrough));
    HV_LOG_RAW("reg_00_ca_vg_cs2_convert_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_50, reg_00_ca_vg_cs2_convert_func_clk_en));
    HV_LOG_RAW("reg_00_ca_vg_cs2_convert_on = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_50, reg_00_ca_vg_cs2_convert_on));
    HV_LOG_RAW("reg_00_ca_vg_cs2_convert_mode = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_50, reg_00_ca_vg_cs2_convert_mode));
    HV_LOG_RAW("reg_00_ca_vg_c42_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_90, reg_00_ca_vg_c42_func_clk_en));
    HV_LOG_RAW("reg_00_ca_vg_c42_on = %u",     HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_90, reg_00_ca_vg_c42_on));
    HV_LOG_RAW("reg_00_ca_vg_c20_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_00_90, reg_00_ca_vg_c20_func_clk_en));
    HV_LOG_RAW("reg_00_422_420_en = %u", HV_R32_FIELD(DISP_TOP_C422_420_00_00, reg_00_422_420_en));
    HV_LOG_RAW("reg_00_ca_data_mode = %u (0:444 1:422 2:420)", HV_R32_FIELD(DISP_TOP_DPU_CA_DPC_00_04, reg_00_ca_data_mode));
    HV_LOG_RAW("reg_00_ca_data_bitwidth = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_DPC_00_04, reg_00_ca_data_bitwidth));

    HV_LOG_RAW("reg_m_data_mode = %u (Mainpath 0:444; 1:422; 2:420)", HV_R32_FIELD(DISP_TOP_DPU_SR_DPC_08, reg_m_data_mode));
    HV_LOG_RAW("reg_m_data_width = %u (Mainpath 0:6bit; 1:8bit; 2:10bit; 3:12bit)", HV_R32_FIELD(DISP_TOP_DPU_SR_DPC_08, reg_m_data_width));
    HV_LOG_RAW("reg_m_frc_framesync_sel = %u (Mainpath 0:ddr data; 1:framesync data)", HV_R32_FIELD(DISP_TOP_DPU_SR_DPC_08, reg_m_frc_framesync_sel));

    HV_LOG_RAW("reg_02_420_422_en = %u", HV_R32_FIELD(DISP_TOP_C420_422_02_00, reg_02_420_422_en));
    HV_LOG_RAW("reg_sr_c24_on = %u", HV_R32_FIELD(DISP_TOP_SRP_TOP_08, reg_sr_c24_on));
    HV_LOG_RAW("reg_sr_cs1_convert_on = %u", HV_R32_FIELD(DISP_TOP_SRP_TOP_14, reg_sr_cs1_convert_on));
    HV_LOG_RAW("reg_sr_cs1_convert_mode= %u", HV_R32_FIELD(DISP_TOP_SRP_TOP_14, reg_sr_cs1_convert_mode));

    HV_LOG_RAW("RX ColorFormatType = %s",     sColorFormatType[pstChannelManager->astChannelData[0].stVideoConfigParams.stColor.eClrFormat]);
    HV_LOG_RAW("RX ColorDepthType = %s",      sColorDepthType[pstChannelManager->astChannelData[0].stVideoConfigParams.stColor.eClrDepth]);
    HV_LOG_RAW("enAspectRatio = %u",          pstChannelManager->astChannelData[0].stVideoConfigParams.enAspectRatio);
    HV_LOG_RAW("channel bOsdVrrEnable=%u",    pstChannelManager->astChannelData[0].stVideoConfigParams.bOsdVrrEnable);
    HV_LOG_RAW("flash ucFreeSync=%u",         HV_COMMON_DATABASE_GET(UserData, ucFreeSync));
    HV_LOG_RAW("uiInputVideoWidth = %u",      pstChannelManager->astChannelData[0].stVideoConfigParams.uiInputVideoWidth);
    HV_LOG_RAW("uiInputVideoHight = %u",      pstChannelManager->astChannelData[0].stVideoConfigParams.uiInputVideoHight);
    HV_LOG_RAW("uiInputVideoHtotal = %u",     pstChannelManager->astChannelData[0].stVideoConfigParams.uiInputVideoHtotal);
    HV_LOG_RAW("uiInputVideoVtotal = %u",     pstChannelManager->astChannelData[0].stVideoConfigParams.uiInputVideoVtotal);
    HV_LOG_RAW("uiInputFrameRate = %u",        pstChannelManager->astChannelData[0].stVideoConfigParams.uiInputFrameRate);

    HV_LOG_RAW("uiDdrOrWtrVideoWidth = %u",   pstChannelManager->astChannelData[0].stVideoConfigParams.uiDdrOrWtrVideoWidth);
    HV_LOG_RAW("uiDdrOrWtrVideoHight = %u",   pstChannelManager->astChannelData[0].stVideoConfigParams.uiDdrOrWtrVideoHight);

    HV_LOG_RAW("uiOutputVideoWidth = %u",     pstChannelManager->astChannelData[0].stVideoConfigParams.uiOutputVideoWidth);
    HV_LOG_RAW("uiOutputVideoHight = %u",     pstChannelManager->astChannelData[0].stVideoConfigParams.uiOutputVideoHight);
    HV_LOG_RAW("uiOutputVideoHtotal = %u",    pstChannelManager->astChannelData[0].stVideoConfigParams.uiOutputVideoHtotal);
    HV_LOG_RAW("uiOutputVideoVtotal = %u",    pstChannelManager->astChannelData[0].stVideoConfigParams.uiOutputVideoVtotal);
    HV_LOG_RAW("uiOutputFrameRate = %u",      pstChannelManager->astChannelData[0].stVideoConfigParams.uiOutputFrameRate);
    HV_LOG_RAW("@@@@@@@@@@@@@@@@@@@@@@@@Main Channel end@@@@@@@@@@@@@@@@@@@@@@@@");

#ifdef CONFIG_USER_DOUBLE_CHANNEL_ON
    if (PXP_MODE_CLOSE != pstChannelManager->stChannelFlashConfig.enFlashPxPMode)
    {
        HV_LOG_RAW("@@@@@@@@@@@@@@@@@@@@@@@@Sub Channel begin@@@@@@@@@@@@@@@@@@@@@@@@");
        HV_LOG_RAW("Current SearchPort Errorcode = %s", GetErrorCode(pstChannelManager->astChannelData[1].uiErrorCode));
        // DisplayTimingMode enTimingMode = pstChannelManager->astChannelData[1].stVideoConfigParams.enTimingMode;
        // HV_LOG_RAW("Current timing Mode = %s", s_strTimingMode[enTimingMode]);
        DisplayDataPathMode enDataPathMode = pstChannelManager->astChannelData[1].stVideoConfigParams.enDataPathMode;
        HV_LOG_RAW("Current DisplayDataPathMode = %s", s_strDataPathMode[enDataPathMode]);
        HV_LOG_RAW("reg_01_ca_vg_c02_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_24, reg_01_ca_vg_c02_func_clk_en));
        HV_LOG_RAW("reg_01_420_422_en = %u", HV_R32_FIELD(DISP_TOP_C420_422_01_00, reg_01_420_422_en));
        HV_LOG_RAW("reg_01_ca_vg_yuv422to444_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_28, reg_01_ca_vg_yuv422to444_func_clk_en));
        HV_LOG_RAW("reg_01_ca_vg_pair_mapping_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_24, reg_01_ca_vg_pair_mapping_en));
        HV_LOG_RAW("reg_01_ca_vg_cs1_convert_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_30, reg_01_ca_vg_cs1_convert_func_clk_en));
        HV_LOG_RAW("reg_01_ca_vg_csc1_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_30, reg_01_ca_vg_csc1_en));
        HV_LOG_RAW("reg_01_ca_vg_hdr_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_50, reg_01_ca_vg_hdr_func_clk_en));
        HV_LOG_RAW("reg_01_ct_ldg_hdr_passthrough = %u", HV_R32_FIELD(DISP_TOP_LDG_HDR_REG_01_00, reg_01_ct_ldg_hdr_passthrough));
        HV_LOG_RAW("reg_01_ca_vg_cs2_convert_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_50, reg_01_ca_vg_cs2_convert_func_clk_en));
        HV_LOG_RAW("reg_01ca_vg_cs2_convert_on = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_50, reg_01_ca_vg_cs2_convert_on));
        HV_LOG_RAW("reg_01_ca_vg_cs2_convert_mode = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_50, reg_01_ca_vg_cs2_convert_mode));
        HV_LOG_RAW("reg_01_ca_vg_c42_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_90, reg_01_ca_vg_c42_func_clk_en));
        HV_LOG_RAW("reg_01_ca_vg_c42_on = %u",     HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_90, reg_01_ca_vg_c42_on));
        HV_LOG_RAW("reg_01_ca_vg_c20_func_clk_en = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_VGSF_01_90, reg_01_ca_vg_c20_func_clk_en));
        HV_LOG_RAW("reg_01_422_420_en = %u", HV_R32_FIELD(DISP_TOP_C422_420_01_00, reg_01_422_420_en));
        HV_LOG_RAW("reg_01_ca_data_mode = %u (0:444 1:422 2:420)", HV_R32_FIELD(DISP_TOP_DPU_CA_DPC_01_04, reg_01_ca_data_mode));
        HV_LOG_RAW("reg_01_ca_data_bitwidth = %u", HV_R32_FIELD(DISP_TOP_DPU_CA_DPC_01_04, reg_01_ca_data_bitwidth));

        HV_LOG_RAW("reg_s_data_mode = %u (Mainpath 0:444; 1:422; 2:420)", HV_R32_FIELD(DISP_TOP_DPU_SR_DPC_10, reg_s_data_mode));
        HV_LOG_RAW("reg_s_data_width = %u (Mainpath 0:6bit; 1:8bit; 2:10bit; 3:12bit)", HV_R32_FIELD(DISP_TOP_DPU_SR_DPC_10, reg_s_data_width));
        HV_LOG_RAW("reg_s_frc_framesync_sel = %u (Mainpath 0:ddr data; 1:framesync data)", HV_R32_FIELD(DISP_TOP_DPU_SR_DPC_10, reg_s_frc_framesync_sel));

        HV_LOG_RAW("reg_03_420_422_en = %u", HV_R32_FIELD(DISP_TOP_C420_422_03_00, reg_03_420_422_en));
        HV_LOG_RAW("reg_sr_c24_on = %u", HV_R32_FIELD(DISP_TOP_SRP_S_TOP_08, reg_sr_c24_on));
        HV_LOG_RAW("reg_sr_cs1_convert_on = %u", HV_R32_FIELD(DISP_TOP_SRP_S_TOP_14, reg_sr_cs1_convert_on));
        HV_LOG_RAW("reg_sr_cs1_convert_mode = %u", HV_R32_FIELD(DISP_TOP_SRP_S_TOP_14, reg_sr_cs1_convert_mode));
        HV_LOG_RAW("ColorFormatType = %s",        sColorFormatType[pstChannelManager->astChannelData[1].stVideoConfigParams.stColor.eClrFormat]);
        HV_LOG_RAW("ColorDepthType = %s",         sColorDepthType[pstChannelManager->astChannelData[1].stVideoConfigParams.stColor.eClrDepth]);
        HV_LOG_RAW("uiInputVideoWidth = %u",      pstChannelManager->astChannelData[1].stVideoConfigParams.uiInputVideoWidth);
        HV_LOG_RAW("uiInputVideoHight = %u",      pstChannelManager->astChannelData[1].stVideoConfigParams.uiInputVideoHight);
        HV_LOG_RAW("uiInputVideoHtotal = %u",     pstChannelManager->astChannelData[1].stVideoConfigParams.uiInputVideoHtotal);
        HV_LOG_RAW("uiInputVideoVtotal = %u",     pstChannelManager->astChannelData[1].stVideoConfigParams.uiInputVideoVtotal);
        HV_LOG_RAW("uiInputFrameRate = %u",       pstChannelManager->astChannelData[1].stVideoConfigParams.uiInputFrameRate);

        HV_LOG_RAW("uiDdrOrWtrVideoWidth = %u",   pstChannelManager->astChannelData[1].stVideoConfigParams.uiDdrOrWtrVideoWidth);
        HV_LOG_RAW("uiDdrOrWtrVideoHight = %u",   pstChannelManager->astChannelData[1].stVideoConfigParams.uiDdrOrWtrVideoHight);

        HV_LOG_RAW("uiOutputVideoWidth = %u",     pstChannelManager->astChannelData[1].stVideoConfigParams.uiOutputVideoWidth);
        HV_LOG_RAW("uiOutputVideoHight = %u",     pstChannelManager->astChannelData[1].stVideoConfigParams.uiOutputVideoHight);
        HV_LOG_RAW("uiOutputVideoHtotal = %u",    pstChannelManager->astChannelData[1].stVideoConfigParams.uiOutputVideoHtotal);
        HV_LOG_RAW("uiOutputVideoVtotal = %u",    pstChannelManager->astChannelData[1].stVideoConfigParams.uiOutputVideoVtotal);
        HV_LOG_RAW("uiOutputFrameRate = %u",      pstChannelManager->astChannelData[1].stVideoConfigParams.uiOutputFrameRate);
        HV_LOG_RAW("@@@@@@@@@@@@@@@@@@@@@@@@Sub Channel end@@@@@@@@@@@@@@@@@@@@@@@@");
    }
#endif

    UCHAR8 ucHflipSwitch = HV_COMMON_DATABASE_GET(DiagData, stDisplayDebug.bHflipEnable);
    UCHAR8 ucVflipSwitch = HV_COMMON_DATABASE_GET(DiagData, stDisplayDebug.bVflipEnable);
    HV_LOG_RAW("ucHflipSwitch =%d", ucHflipSwitch);
    HV_LOG_RAW("ucHflipSwitch =%d", ucVflipSwitch);

    USHORT16 usMaxMainFBufferHsize = HV_COMMON_DATABASE_GET(DiagData, stDisplayDebug.usMaxMainFrameBufferHsize);
    USHORT16 usMaxMainFBufferVsize = HV_COMMON_DATABASE_GET(DiagData, stDisplayDebug.usMaxMainFrameBufferVsize);
    HV_LOG_RAW("usMaxMainFrameBufferHsize =%d, usMaxMainFrameBufferVsize=%d.", usMaxMainFBufferHsize, usMaxMainFBufferVsize);
    HV_LOG_RAW("main channel enChannelSrcLinkPortIndex=%u", pstChannelManager->astChannelData[0].enChannelSrcLinkPortIndex);
    HV_LOG_RAW("data base ucVideoSource=%u", HV_COMMON_DATABASE_GET(UserData, ucVideoSource));
    HV_LOG_RAW("data base bAutoVideoSrcSelSw=%u", HV_COMMON_DATABASE_GET(UserData, bAutoVideoSrcSelSw));
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAIN_MONTAGE)
    HV_LOG_RAW("bMainMontageSw=%u, usMontageInHsta=%u, usMontageInHend=%u, usMontageInVsta=%u, usMontageInVend=%u", HV_COMMON_DATABASE_GET(UserData, bMainMontageSw),\
    HV_COMMON_DATABASE_GET(UserData, usMontageInHsta), HV_COMMON_DATABASE_GET(UserData, usMontageInHend), HV_COMMON_DATABASE_GET(UserData, usMontageInVsta), HV_COMMON_DATABASE_GET(UserData, usMontageInVend));
#endif
#ifdef CONFIG_USER_DOUBLE_CHANNEL_ON
    USHORT16 usMaxSubFBufferHsize = HV_COMMON_DATABASE_GET(DiagData, stDisplayDebug.usMaxPipFrameBufferHsize);
    USHORT16 usMaxSubFBufferVsize = HV_COMMON_DATABASE_GET(DiagData, stDisplayDebug.usMaxPipFrameBufferVsize);
    HV_LOG_RAW("usMaxPipFrameBufferHsize =%d, usMaxPipFrameBufferVsize=%d.", usMaxSubFBufferHsize, usMaxSubFBufferVsize);
    HV_LOG_RAW("ucPipPosition =%u", HV_COMMON_DATABASE_GET(UserData, ucPipPosition));
    HV_LOG_RAW("ucPipSize =%u", HV_COMMON_DATABASE_GET(UserData, ucPipSize));
    HV_LOG_RAW("usPipSmallWindowHSize =%u", HV_COMMON_DATABASE_GET(UserData, usPipSmallWindowHSize));
    HV_LOG_RAW("usPipSmallWindowVSize =%u", HV_COMMON_DATABASE_GET(UserData, usPipSmallWindowVSize));
    HV_LOG_RAW("usPipMiddleWindowHSize =%u", HV_COMMON_DATABASE_GET(UserData, usPipMiddleWindowHSize));
    HV_LOG_RAW("usPipMiddleWindowVSize =%u", HV_COMMON_DATABASE_GET(UserData, usPipMiddleWindowVSize));
    HV_LOG_RAW("usPipBigWindowHSize =%u", HV_COMMON_DATABASE_GET(UserData, usPipBigWindowHSize));
    HV_LOG_RAW("usPipBigWindowVSize =%u", HV_COMMON_DATABASE_GET(UserData, usPipBigWindowVSize));
    HV_LOG_RAW("ucProportion=%u", HV_COMMON_DATABASE_GET(UserData, ucProportion));
    
    HV_LOG_RAW("sub channel enChannelSrcLinkPortIndex=%u", pstChannelManager->astChannelData[1].enChannelSrcLinkPortIndex);
    HV_LOG_RAW("channel bFlashSubFakeVideoSw=%u", pstChannelManager->stChannelFlashConfig.bFlashSubFakeVideoSw);
    HV_LOG_RAW("database bMagnifyGlassSw=%u", HV_COMMON_DATABASE_GET(UserData, bMagnifyGlassSw));
    HV_LOG_RAW("channel FlashPxPMode=%u", pstChannelManager->stChannelFlashConfig.enFlashPxPMode);
    HV_LOG_RAW("database ucPxPMode=%u", HV_COMMON_DATABASE_GET(UserData, ucPxPMode));
    HV_LOG_RAW("MagnifyGlassRatio=%u", HV_COMMON_DATABASE_GET(UserData, fMagnifyGlassScalerUpRatio));
    HV_LOG_RAW("MagnifyGlassSize H=%u, V=%u", HV_COMMON_DATABASE_GET(UserData, usMagnifyGlassHsize), HV_COMMON_DATABASE_GET(UserData, usMagnifyGlassVsize));
    HV_LOG_RAW("MagnifyGlassPos H=%u, V=%u", HV_COMMON_DATABASE_GET(UserData, usMagnifyGlassPositionH), HV_COMMON_DATABASE_GET(UserData, usMagnifyGlassPositionV));
#endif
    return 0;
}
HV_SHELL_EXPORT_CMD(show_dpu_config, Hv_Shell_ShowDpuConfig, "show dpu all ip config");

int Hv_Shell_Edidconfig(int argc, char* argv[])
{
    HvFactoryEdidInfo stEdidInfo = {0};
    if (argc < 2)
    {
        HV_LOG_RAW("show_edid_info port_num");
        return 0;
    }
    Hv_Mw_InputPort_GetFactoryEdidInfo(atoi(argv[1]), &stEdidInfo);
    HV_LOG_RAW("Manufacture %c%c%c", stEdidInfo.acFactName[0], stEdidInfo.acFactName[1], stEdidInfo.acFactName[2]);
    HV_LOG_RAW("ProductCode %x", stEdidInfo.usProductCode);
    HV_LOG_RAW("SerialNo %x", stEdidInfo.uiSerialNum);
    HV_LOG_RAW("Year %d", stEdidInfo.usYear);
    HV_LOG_RAW("Weak %d", stEdidInfo.ucWeek);
    HV_LOG_RAW("Version %d", stEdidInfo.ucVersion);
    HV_LOG_RAW("Revision %d", stEdidInfo.ucRevision);
    HV_LOG_RAW("MonitorName %c%c%c%c%c%c%c%c%c%c%c%c%c", stEdidInfo.acMonitorName[0], stEdidInfo.acMonitorName[1], stEdidInfo.acMonitorName[2],
                                                         stEdidInfo.acMonitorName[3], stEdidInfo.acMonitorName[4], stEdidInfo.acMonitorName[5],
                                                         stEdidInfo.acMonitorName[6], stEdidInfo.acMonitorName[7], stEdidInfo.acMonitorName[8],
                                                         stEdidInfo.acMonitorName[9], stEdidInfo.acMonitorName[10], stEdidInfo.acMonitorName[11],
                                                         stEdidInfo.acMonitorName[12]);
    HV_LOG_RAW("ExtFlag %x", stEdidInfo.ucExtFlag);
    HV_LOG_RAW("StorageType %d", stEdidInfo.ucStorageType);
    HV_LOG_RAW("Checksum %x %x %x %x", stEdidInfo.aucCheckSumValue[0], stEdidInfo.aucCheckSumValue[1], stEdidInfo.aucCheckSumValue[2], stEdidInfo.aucCheckSumValue[3]);
    HV_LOG_RAW("ChecksumStatus %d", stEdidInfo.bCheckSumStatus);

    return 0;
}

HV_SHELL_EXPORT_CMD(show_edid_info, Hv_Shell_Edidconfig, "show edid info");

int Hv_Shell_ConfigDataPath(int argc, char* argv[])
{
    const PanelParam stPanelParam = Hv_Mw_Panel_GetCurrentPanelParam();
    VideoConfigParams stVideoConfigParams = {0};
    VideoTimingParam    stRxVideoTiming = {0};
    stVideoConfigParams.stColor.eClrDepth = ColorDepthType_8Bit;
    stVideoConfigParams.stColor.eClrFormat = ColorFormatType_RGB;
    stVideoConfigParams.stColor.eClrRange = ColorRangeType_Full_Range;
    stVideoConfigParams.stColor.eClrSpace = ColorSpaceType_SRGB;
    stVideoConfigParams.stColor.ucPixelRepe = 0;
    stVideoConfigParams.stHdrParam.xType = SDR_TYPE;
    stVideoConfigParams.stVRRInfoParam.bVRREnable = HV_FALSE;

    stRxVideoTiming.bInterlacedMode = HV_FALSE;
    stRxVideoTiming.uiFreqKHz = (UINT32)((UINT32)stPanelParam.usPanelHtotalType * stPanelParam.usPanelVtotalType * stPanelParam.usPanelFrameRateType);
    stRxVideoTiming.usFrameRate = stPanelParam.usPanelFrameRateType;
    stRxVideoTiming.usHActive = stPanelParam.usPanelHactive;
    stRxVideoTiming.usHTotal = stPanelParam.usPanelHtotalType;
    stRxVideoTiming.usVActive = stPanelParam.usPanelVactive;
    stRxVideoTiming.usVTotal = stPanelParam.usPanelVtotalType;

    //Hv_Mw_Video_ConfigDisplayDataPath(CHANNEL_TYPE_MAIN, &stVideoConfigParams, &stRxVideoTiming);

    HV_LOG_RAW("Set the Data path AS pannel: HTotal:%d,Vtotal:%d,FrameRate:%d,\r\n",
        stRxVideoTiming.usHTotal, stRxVideoTiming.usVTotal, stRxVideoTiming.usFrameRate);

    return 0;
}
HV_SHELL_EXPORT_CMD(set_datapath, Hv_Shell_ConfigDataPath, "Set Datapath As Pannel Suggest");

int Hv_Shell_SetDpuDdrSize(int argc, char* argv[])
{
    if (4 == argc)
    {
        if (0 == atoi(argv[1]))
        {
            USHORT16 usMaxMainFBHsize = atoi(argv[2]);
            USHORT16 usMaxMainFBVsize = atoi(argv[3]);
            HV_COMMON_DATABASE_SET(DiagData, stDisplayDebug.usMaxMainFrameBufferHsize, usMaxMainFBHsize);
            HV_COMMON_DATABASE_SET(DiagData, stDisplayDebug.usMaxMainFrameBufferVsize, usMaxMainFBVsize);
            HV_LOG_RAW("set usMaxMainFBHsize=%d,usMaxMainFBVsize=%d.\r\n", usMaxMainFBHsize, usMaxMainFBVsize);
        }
        else
        {
            USHORT16 usMaxSubFBHsize = atoi(argv[2]);
            USHORT16 usMaxSubFBVsize = atoi(argv[3]);
            HV_COMMON_DATABASE_SET(DiagData, stDisplayDebug.usMaxPipFrameBufferHsize, usMaxSubFBHsize);
            HV_COMMON_DATABASE_SET(DiagData, stDisplayDebug.usMaxPipFrameBufferVsize, usMaxSubFBVsize);
            HV_LOG_RAW("set usMaxSubFBHsize=%d,usMaxSubFBVsize=%d.\r\n", usMaxSubFBHsize, usMaxSubFBVsize);
        }

        HV_ASSERT_SUCCESS(SendNotifyMessageToSystemTask(SETTING_PARAM_ID_DATA_PATH_RECONFIG, 0));
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_dpu_ddr_size, Hv_Shell_SetDpuDdrSize, "param0:(0-main 1:sub) param1(type int):Hsize , param2(type int):VSsize");

#ifdef CONFIG_USER_DOUBLE_CHANNEL_ON

int Hv_Shell_SetPipWindowSize(int argc, char* argv[])
{
    if (3 == argc)
    {
        USHORT16 usPipWindowHSize = atoi(argv[1]);
        USHORT16 usPipWindowVSize = atoi(argv[2]);
        if (1 == HV_COMMON_DATABASE_GET(UserData, ucPipSize))
        {
            HV_COMMON_DATABASE_SET(UserData, usPipBigWindowHSize, usPipWindowHSize);
            HV_COMMON_DATABASE_SET(UserData, usPipBigWindowVSize, usPipWindowVSize);
        }
        else
        {
            HV_COMMON_DATABASE_SET(UserData, usPipSmallWindowHSize, usPipWindowHSize);
            HV_COMMON_DATABASE_SET(UserData, usPipSmallWindowVSize, usPipWindowVSize);
        }
        HV_LOG_RAW("set usPipWindowHSize=%d,usPipWindowVSize=%d.\r\n", usPipWindowHSize, usPipWindowVSize);

        HV_ASSERT_SUCCESS(SendNotifyMessageToSystemTask(SETTING_PARAM_ID_DATA_PATH_RECONFIG, 0));
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_pip_window_size, Hv_Shell_SetPipWindowSize, "param0(type int):Hsize , param1(type int):VSsize");
#endif
int Hv_Shell_SetDpuMode(int argc, char* argv[])
{
    if (2 == argc)
    {
        UCHAR8 ucValue = atoi(argv[1]);
        HV_COMMON_DATABASE_SET(DiagData, stDisplayDebug.ucVideoDataPathMode, ucValue);
        HV_LOG_RAW("set ucVideoDataPathMode=%u success.\r\n", ucValue);
        HV_ASSERT_SUCCESS(SendNotifyMessageToSystemTask(SETTING_PARAM_ID_DATA_PATH_RECONFIG, 0));
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_dpu_mode, Hv_Shell_SetDpuMode, "0-close and use auto 1:framesync 2:frc-uncompress-yuv444 3:frc-uncompress-yuv422 4:frc-uncompress-yuv420 5:KTX 6:free_run_node1 7:compress-yuv444 8:compress-yuv422");

int Hv_Shell_SetDpuModeFastSwitch(int argc, char* argv[])
{
    if (2 == argc)
    {
        UCHAR8 ucValue = atoi(argv[1]);
        switch (ucValue)
        {
            case 0:
            {
                HV_W32_FIELD(DISP_TOP_DPU_SR_DPC_00, reg_en_no_latch, 0);
                Hv_Cal_DpuScaler_DtcTimingSel(3);
                Hv_Cal_DpuScaler_DtcFrameSyncVrrModeEn(1);
                Hv_Vos_MSleep(100);
                Hv_Cal_DpuScaler_DpcSrpMainFrcFrameSyncSel(1);
                break;
            }
            case 1:
            {
                HV_W32_FIELD(DISP_TOP_DPU_SR_DPC_00, reg_en_no_latch, 0);
                Hv_Cal_DpuScaler_DtcTimingSel(1);
                Hv_Cal_DpuScaler_DtcFrameSyncVrrModeEn(0);
                Hv_Cal_DpuScaler_DpcSrpMainFrcFrameSyncSel(0);
                break;
            }
            default:
            {
                break;
            }
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_dpu_mode_fast_switch, Hv_Shell_SetDpuModeFastSwitch, "0:frc switch to framesync 1:framesync switch to frc");

UINT32 DpuGetCaHtotal()
{
    //reg_00_ca_htotal
    UINT32 uiValue = Hv_Cal_DpuScaler_GetDpcCapMainSyncHtotal();
    return uiValue;
}


Status DpuSetCaHtotal(UINT32 uiHtotal)
{
    HV_W32_FIELD(DISP_TOP_DPU_CA_SYNC_00_04, reg_00_ca_htotal, uiHtotal);
    return HV_SUCCESS;
}


int Hv_Shell_SetHdr(int argc, char* argv[])
{
    if(argc == 2)
    {
        UINT32 uiValue = 0;
        uiValue = DpuGetCaHtotal();
        if (0 == strcmp("0", argv[1]))
        {
            uiValue = 0;
            HV_COMMON_DATABASE_SET(UserData, enHdrSwitch, 0);
        }
        else if (0 == strcmp("1", argv[1]))
        {
            uiValue = 1;
            HV_COMMON_DATABASE_SET(UserData, enHdrSwitch, 1);
        }
        else if (0 == strcmp("2", argv[1]))
        {
            uiValue = 2;
            HV_COMMON_DATABASE_SET(UserData, enHdrSwitch, 2);
        }

        HV_ASSERT_SUCCESS(SendNotifyMessageToSystemTask(SETTING_PARAM_ID_HDR_SWITCH, uiValue));
    }
    return 0;
}

HV_SHELL_EXPORT_CMD(hdr, Hv_Shell_SetHdr, "1/2/0");

int Hv_Shell_Hue(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        uiValue = atoi(argv[1]);
        HV_LOG_RAW("Hue %d\r\n", uiValue);
        Hv_App_PQ_SetHue(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(hue, Hv_Shell_Hue, "hue (0-100)");

int Hv_Shell_Deg(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        uiValue = atoi(argv[1]);
        Hv_Mw_PQ_SetGammaLevel(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(deg, Hv_Shell_Deg, "degamma");

int Hv_Shell_PwmDuty(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        uiValue = atoi(argv[1]);
        HV_LOG_RAW("PWM %d\r\n", uiValue);
        Hv_Mw_PQ_SetPwmDuty(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(pwmduty, Hv_Shell_PwmDuty, "pwmduty");



int Hv_Shell_Deo(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        uiValue = atoi(argv[1]);
        Hv_Mw_PQ_SetOsdGammaLevel(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(deo, Hv_Shell_Deo, "osd degamma");


#define CHIP_NUM (24)

static UCHAR8 prepArray[400]={0};
static USHORT16 usprepArray[800]={0};
static UINT32  Orig2ArrayArray[200]={0};
static USHORT16 Orig2Arr[200]={0};




static USHORT16 usMapMtx[1152]=
{
//#include"mp.h"
};
VOID Mapping2(USHORT16* pusLD, USHORT16* pusSend, USHORT16 usLen)
{
    UINT32 uiIndex = 0;
    for(uiIndex = 0; uiIndex < usLen; uiIndex++)
    {
        pusSend[uiIndex] = 0xd000 | pusLD[uiIndex]>>6;
    }
    return;
}


static USHORT16 usLDData[1152]={0};
static USHORT16 usPwm[1152]={
    0xd200, 0xd200, 0xd200, 0xd200,
};
#define BCON_RAM_START_ADDR    0x80000000
#define REG_BCON_RAM_DATA_OFFSET     0x1104FF00
#define REG_BCON_RAM_DATA_ENTRY   0x1104FF04



USHORT16 auiData[200] = {0};
int Hv_Shell_Bcon(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    UINT32 uiValue1 = 0;
    
    int i = 0;
    if(argc == 3)
    {
        uiValue = atoi(argv[1]);
        uiValue1 = atoi(argv[2]);
        if(uiValue == 7)
        {
            HV_LOG_RAW("init %d", uiValue);
           Hv_Mw_Bcon_HY8603SetLanes(0, (1<<1)|(1<<4));
            Hv_Vos_MSleep(33);
            HV_LOG_RAW("init1 %d", uiValue);
            Hv_Mw_Bcon_Init(3, 2000);
            Hv_Vos_MSleep(33);
            HV_LOG_RAW("init2 %d", uiValue);
            Hv_Mw_Bcon_HY8603_Init();
            Hv_Vos_MSleep(33);
            HV_LOG_RAW("init3 %d", uiValue);

            memset(auiData, 0x3f, 200*2);
            Hv_Mw_Bcon_HY8603BlDataPrep(1, auiData, 100);
            Hv_Vos_MSleep(33);
            HV_LOG_RAW("init4 %d", uiValue);
            Hv_Mw_Bcon_HY8603BlDataSend();
       }
    }
    else
    {
       //  Hv_Mw_Bcon_SetLanes(2, (1<<0)|(1<<1)|(1<<3)|(1<<4));
        //Hv_Vos_MSleep(33);
        //Hv_Mw_Bcon_Init(3, 1800);
        //Hv_Vos_MSleep(33);
        //Hv_Mw_Bcon_HY8603_Init();
        uiValue = atoi(argv[1]);
        if(uiValue == 1)
        {
            UINT32 sLen = 0;

         //  sLen = Hv_Mw_XP7008_PrepCmd(0x10, 0x10+1, input, Orig2Arr);
            //sLen = XsignalSend(BROADCAST_SAME, 0x10, 0x10+1, input);
            //Orig2ArrayArray[0]=0x000e0000;
            //Orig2ArrayArray[0] = 0x12345678;
            //Orig2ArrayArray[1] = 0xaabbccdd;
            for(int i  = 0; i < sLen; i++)
            {
                HV_LOG_INFO(PQ, "[%d]0x%08x", i, Orig2Arr[i]);
            }
            Hv_Mw_Bcon_XP7008BlDataPrep(1, Orig2Arr, sLen);
            Hv_Mw_Bcon_XP7008BlDataPrep(3, Orig2Arr, sLen);
            Hv_Mw_Bcon_XP7008_SendData();
            HV_LOG_INFO(PQ, "SEND");
        }
        if(uiValue == 2)
        {

            UINT32 sLen = 0;
            //sLen = Hv_Mw_XP7008_PrepCmd(0x10, 0x10+1, input, Orig2Arr);
            //sLen = XsignalSend(BROADCAST_SAME, 0x10, 0x10+1, input);
            HV_W32_FIELD(RX_KV_DIMMER_CTRL_REG1_REG_RX_SEL, reg_sin_en, 0);
            HV_W32_FIELD(RX_KV_DIMMER_CTRL_REG1_REG_RX_SEL, reg_sin_en, 1);
            for(int i  = 0; i < sLen; i++)
            {
                HV_LOG_INFO(PQ, "[%d]0x%08x", i, Orig2Arr[i]);
            }

            Hv_Mw_Bcon_XP7008BlDataPrep(1, Orig2Arr, sLen);
            Hv_Mw_Bcon_XP7008BlDataPrep(2, Orig2Arr, sLen);
            Hv_Mw_Bcon_XP7008BlDataPrep(3, Orig2Arr, sLen);
            Hv_Mw_Bcon_XP7008BlDataPrep(5, Orig2Arr, sLen);
            Hv_Mw_Bcon_XP7008BlDataPrep(6, Orig2Arr, sLen);
            Hv_Mw_Bcon_XP7008BlDataPrep(8, Orig2Arr, sLen);
            Hv_Mw_Bcon_XP7008_SendData();
            //Hv_Mw_Bcon_BlDataSend();
            HV_LOG_INFO(PQ, "SEND");
        
        }
        if(uiValue == 3)
        {

            UINT32 sLen = 0;
            
            HV_W32_FIELD(RX_KV_DIMMER_CTRL_REG1_REG_RX_SEL, reg_lut_sel, 1);
            HV_W32(REG_BCON_RAM_DATA_OFFSET, 0x0);
            HV_W32(REG_BCON_RAM_DATA_OFFSET, BCON_RAM_START_ADDR);
            for(int i = 0; i < 50; i++) 
            {
                int uiI = HV_R32(REG_BCON_RAM_DATA_ENTRY);
                HV_LOG_RAW("%04x ",  uiI);
            }

            HV_W32_FIELD(RX_KV_DIMMER_CTRL_REG1_REG_RX_SEL, reg_lut_sel, 0);
        }
        if(uiValue == 4)
        {
            
                Hv_Mw_Bcon_ReadData(13, 50, auiData);
                for(int i = 0; i < 50; i++)
                {
                    HV_LOG_RAW("0x%04x", auiData[i]);
                }
        }


    }
    if(argc == 4)
    { 
        uiValue = atoi(argv[1]);
        UINT32 uiValue1 = atoi(argv[2]);
        
        if(uiValue == 1)
        {
            HV_LOG_INFO(PQ, "IN %d", uiValue);
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_0, reg_gpio22_func_sel, 3);
            for(int k = 0; k < 1152; k++)
            {
                usPwm[k] = uiValue1;
            }

            for(int k = 0; k < 20; k++)
            {
                //HV_LOG_INFO(PQ, "%04x", usPwm[k]);
            }

            //Mapping2(usLDData, usPwm, 192);
            UINT32 sLen = 0;
            //sLen = XsignalSendPwm(BROADCAST_DIFF, 0x0, 0x10, usPwm);
            sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, usPwm, usprepArray);
            Hv_Mw_Bcon_XP7008BlDataPrep(8, usprepArray, sLen);
            sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[192], usprepArray);
            Hv_Mw_Bcon_XP7008BlDataPrep(1, &usprepArray[0], sLen);
            sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[192*2], usprepArray);
            Hv_Mw_Bcon_XP7008BlDataPrep(5, &usprepArray[0], sLen);
            sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[192*3], usprepArray);
            Hv_Mw_Bcon_XP7008BlDataPrep(2, &usprepArray[0], sLen);
            sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[192*4], usprepArray);
            Hv_Mw_Bcon_XP7008BlDataPrep(3, &usprepArray[0], sLen);
            sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[192*5], usprepArray);
            Hv_Mw_Bcon_XP7008BlDataPrep(6, &usprepArray[0], sLen);
            //Hv_Mw_Bcon_BlDataPrep(6, &usprepArray[144*6], sLen);
            //Hv_Mw_Bcon_BlDataPrep(7, &usprepArray[144*7], sLen);
            //Hv_Mw_Bcon_BlDataSend();
            Hv_Mw_Bcon_XP7008_SendData();
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_0, reg_gpio22_func_sel, 1);

            HV_LOG_INFO(BCON, "Spi send done1");
        }
        if(uiValue == 3)
        {
            USHORT16 sLen = 0;
            for(int k = 0; k < 192; k++)
            {
                memset(usLDData, 0, 192*2);
                usLDData[k] = 0xFFFF;

                Mapping2(usLDData, usPwm, 192);

                sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[0], usprepArray);
                Hv_Mw_Bcon_XP7008BlDataPrep(8, &usprepArray[0], sLen);
                Hv_Mw_Bcon_XP7008BlDataPrep(1, &usprepArray[0], sLen);
                Hv_Mw_Bcon_XP7008BlDataPrep(5, &usprepArray[0], sLen);

                Hv_Mw_Bcon_XP7008BlDataPrep(2, usprepArray, sLen);
                Hv_Mw_Bcon_XP7008BlDataPrep(3, &usprepArray[0], sLen);

                Hv_Mw_Bcon_XP7008BlDataPrep(6, &usprepArray[0], sLen);
                //       Hv_Mw_Bcon_BlDataSend();
                Hv_Mw_Bcon_XP7008_SendData();
                Hv_Vos_MSleep(30);
            }
          

        }
        if(uiValue == 4)
        {
            UINT32 uiValue2 = atoi(argv[3]);
            HV_LOG_INFO(PQ, "IN %d", uiValue);
            
            for(int i = 0 ;i < 1152; i++)
            {
                HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_0, reg_gpio22_func_sel, 3);
                for(int k = 0; k < 1152; k++)
                {
                    usLDData[k] = 0x0;
                }
                usLDData[i] = 0xff34;
                Mapping2(usLDData, usPwm, 1152);
                UINT32 sLen = 0;
                sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[192*1], usprepArray);
                Hv_Mw_Bcon_XP7008BlDataPrep(1, &usprepArray[0], sLen);
                sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[192*3], usprepArray);
                Hv_Mw_Bcon_XP7008BlDataPrep(2, usprepArray, sLen);
                sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[192*4], usprepArray);
                Hv_Mw_Bcon_XP7008BlDataPrep(3, &usprepArray[0], sLen);
                sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[192*2], usprepArray);
                Hv_Mw_Bcon_XP7008BlDataPrep(5, &usprepArray[0], sLen);

                sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[192*5], usprepArray);
                Hv_Mw_Bcon_XP7008BlDataPrep(6, &usprepArray[0], sLen);

                sLen = Hv_Mw_XP7008_PrepData( 0x0, 0x10, &usPwm[192*0], usprepArray);
                Hv_Mw_Bcon_XP7008BlDataPrep(8, &usprepArray[0], sLen);
                //Hv_Mw_Bcon_BlDataSend();
                Hv_Mw_Bcon_XP7008_SendData();
                HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_0, reg_gpio22_func_sel, 1);

                Hv_Vos_MSleep(20);
            }
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(bcon, Hv_Shell_Bcon, "Bcon");




int Hv_Shell_GetLum(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    uiValue = Hv_Mw_PQ_GetPicPWM();
    HV_LOG_RAW("PWM %d\r\n", uiValue);
    return 0;
}
HV_SHELL_EXPORT_CMD(getlum, Hv_Shell_GetLum, "GetLum of current frame");



int Hv_Shell_SetHue(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 3)
    {
        uiValue = atoi(argv[2]);
        if (0 == strcmp("r", argv[1]))//hue
        {
            HV_COMMON_DATABASE_SET(UserData, ucHueByR, uiValue);
            Hv_Mw_PQ_CMSetHue(PQ_CM_R, uiValue);
        }
        else if (0 == strcmp("g", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucHueByG, uiValue);
            Hv_Mw_PQ_CMSetHue(PQ_CM_G, uiValue);
        }
        else if (0 == strcmp("b", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucHueByB, uiValue);
            Hv_Mw_PQ_CMSetHue(PQ_CM_B, uiValue);
        }
        else if (0 == strcmp("c", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucHueByC, uiValue);
            Hv_Mw_PQ_CMSetHue(PQ_CM_C, uiValue);
        }
        else if (0 == strcmp("m", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucHueByM, uiValue);
            Hv_Mw_PQ_CMSetHue(PQ_CM_M, uiValue);
        }
        else if (0 == strcmp("y", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucHueByY, uiValue);
            Hv_Mw_PQ_CMSetHue(PQ_CM_Y, uiValue);
        }
        else if (0 == strcmp("s", argv[1]))
        {
            Hv_Mw_PQ_CMSetHue(PQ_CM_SKIN, uiValue);
        }
        else if (0 == strcmp("a", argv[1]))
        {
            for(int i = 0; i < 256; i++)
            {
                Hv_Mw_PQ_CMSetHue(PQ_CM_R, i);
                Hv_Mw_PQ_CMSetHue(PQ_CM_G, i);
                Hv_Mw_PQ_CMSetHue(PQ_CM_B, i);
                Hv_Mw_PQ_CMSetHue(PQ_CM_C, i);
                Hv_Mw_PQ_CMSetHue(PQ_CM_M, i);
                Hv_Mw_PQ_CMSetHue(PQ_CM_Y, i);
                Hv_Vos_MSleep(30);
                HV_LOG_RAW("Hue %d\r\n", i);
            }
        }
    }

    return 0;
}
HV_SHELL_EXPORT_CMD(cmhue, Hv_Shell_SetHue, "cmhue (r-y) (0-3)");

int Hv_Shell_SetLum(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 3)
    {

        uiValue = atoi(argv[2]);
        if (0 == strcmp("r", argv[1]))//hue
        {
            HV_COMMON_DATABASE_SET(UserData, ucLumByR, uiValue);
            Hv_Mw_PQ_CMSetLum(PQ_CM_R, uiValue);
        }
        else if (0 == strcmp("g", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucLumByG, uiValue);
            Hv_Mw_PQ_CMSetLum(PQ_CM_G, uiValue);
        }
        else if (0 == strcmp("b", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucLumByB, uiValue);
            Hv_Mw_PQ_CMSetLum(PQ_CM_B, uiValue);
        }
        else if (0 == strcmp("c", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucLumByC, uiValue);
            Hv_Mw_PQ_CMSetLum(PQ_CM_C, uiValue);
        }
        else if (0 == strcmp("m", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucLumByM, uiValue);
            Hv_Mw_PQ_CMSetLum(PQ_CM_M, uiValue);
        }
        else if (0 == strcmp("y", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucLumByY, uiValue);
            Hv_Mw_PQ_CMSetLum(PQ_CM_Y, uiValue);
        }
        else if (0 == strcmp("s", argv[1]))
        {
            Hv_Mw_PQ_CMSetLum(PQ_CM_SKIN, uiValue);
        }
        else if (0 == strcmp("a", argv[1]))
        {
            for(int i = 0; i < 256; i++)
            {
                Hv_Mw_PQ_CMSetLum(PQ_CM_R, i);
                Hv_Mw_PQ_CMSetLum(PQ_CM_G, i);
                Hv_Mw_PQ_CMSetLum(PQ_CM_B, i);
                Hv_Mw_PQ_CMSetLum(PQ_CM_Y, i);
                Hv_Mw_PQ_CMSetLum(PQ_CM_M, i);
                Hv_Mw_PQ_CMSetLum(PQ_CM_C, i);
                Hv_Vos_MSleep(30);
                HV_LOG_RAW("Hue %d\r\n", i);
            }
        }
    }

    return 0;
}
HV_SHELL_EXPORT_CMD(cmlum, Hv_Shell_SetLum, "cmlum (r-y) (0-3)");


int Hv_Shell_SetCm64(int argc, char* argv[])
{
    UINT32 uiIndex = 0;
    UINT32 uiOffset = 0;
    if(argc == 4)
    {
        uiIndex = atoi(argv[2]);
        uiOffset= atoi(argv[3]);
        if (0 == strcmp("h", argv[1]))//sat
        {
            HV_PQ_DATABASE_SET(DiagData, ucDBHueAll[uiIndex], uiOffset);
            Hv_Mw_PQ_CM64AxisSetHue(uiIndex);
        }
        else if (0 == strcmp("s", argv[1]))
        {
            HV_PQ_DATABASE_SET(DiagData, ucDBSatAll[uiIndex], uiOffset);
            Hv_Mw_PQ_CM64AxisSetSat(uiIndex);
        }
        else if (0 == strcmp("l", argv[1]))
        {
            HV_PQ_DATABASE_SET(DiagData, ucDBLumAll[uiIndex], uiOffset);
            Hv_Mw_PQ_CM64AxisSetLum(uiIndex);
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(cm64, Hv_Shell_SetCm64, "cm64 h/s/l index offset ");

int Hv_Shell_SetSat(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 3)
    {

        uiValue = atoi(argv[2]);
        if (0 == strcmp("r", argv[1]))//sat
        {
            HV_COMMON_DATABASE_SET(UserData, ucSatByR, uiValue);
            Hv_Mw_PQ_CMSetSat(PQ_CM_R, uiValue);
        }
        else if (0 == strcmp("g", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucSatByG, uiValue);
            Hv_Mw_PQ_CMSetSat(PQ_CM_G, uiValue);
        }
        else if (0 == strcmp("b", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucSatByB, uiValue);
            Hv_Mw_PQ_CMSetSat(PQ_CM_B, uiValue);
        }
        else if (0 == strcmp("c", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucSatByC, uiValue);
            Hv_Mw_PQ_CMSetSat(PQ_CM_C, uiValue);
        }
        else if (0 == strcmp("m", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucSatByM, uiValue);
            Hv_Mw_PQ_CMSetSat(PQ_CM_M, uiValue);
        }
        else if (0 == strcmp("y", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, ucSatByY, uiValue);
            Hv_Mw_PQ_CMSetSat(PQ_CM_Y, uiValue);
        }
        else if (0 == strcmp("s", argv[1]))
        {
            Hv_Mw_PQ_CMSetSat(PQ_CM_SKIN, uiValue);
        }
        else if (0 == strcmp("a", argv[1]))
        {
            for(int i = 0; i < 256; i++)
            {
                Hv_Mw_PQ_CMSetSat(PQ_CM_R, i);
                Hv_Mw_PQ_CMSetSat(PQ_CM_G, i);
                Hv_Mw_PQ_CMSetSat(PQ_CM_B, i);
                Hv_Mw_PQ_CMSetSat(PQ_CM_Y, i);
                Hv_Mw_PQ_CMSetSat(PQ_CM_M, i);
                Hv_Mw_PQ_CMSetSat(PQ_CM_C, i);
                Hv_Vos_MSleep(30);
                HV_LOG_RAW("Hue %d\r\n", i);
            }
        }
    }
    return 0;
}

HV_SHELL_EXPORT_CMD(cmsat, Hv_Shell_SetSat, "cmsat (r-y) (0-3)");

int Hv_Shell_CmInit(int argc, char* argv[])
{
    Hv_App_PQ_CMInit();
    return 0;
}
HV_SHELL_EXPORT_CMD(cminit, Hv_Shell_CmInit, "cminit");

int Hv_Shell_DrvDataDebug(int argc, char* argv[])
{
    HV_LOG_RAW("CM_R_HUE=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBHueR));
    HV_LOG_RAW("CM_G_HUE=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBHueG));
    HV_LOG_RAW("CM_B_HUE=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBHueB));
    HV_LOG_RAW("CM_C_HUE=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBHueC));
    HV_LOG_RAW("CM_M_HUE=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBHueM));
    HV_LOG_RAW("CM_Y_HUE=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBHueY));
    HV_LOG_RAW("CM_R_SAT=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBSatR));
    HV_LOG_RAW("CM_G_SAT=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBSatG));
    HV_LOG_RAW("CM_B_SAT=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBSatB));
    HV_LOG_RAW("CM_C_SAT=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBSatC));
    HV_LOG_RAW("CM_M_SAT=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBSatM));
    HV_LOG_RAW("CM_Y_SAT=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBSatY));
    HV_LOG_RAW("CM_R_LUM=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBLumR));
    HV_LOG_RAW("CM_G_LUM=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBLumG));
    HV_LOG_RAW("CM_B_LUM=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBLumB));
    HV_LOG_RAW("CM_C_LUM=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBLumC));
    HV_LOG_RAW("CM_M_LUM=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBLumM));
    HV_LOG_RAW("CM_Y_LUM=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBLumY));

    HV_LOG_RAW("Contrast=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, uiDBContrast));
    HV_LOG_RAW("Sharpness=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBSharpness));
    HV_LOG_RAW("Satutation=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBSaturation));
    HV_LOG_RAW("Brightness=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, usDBBrightness));

    HV_LOG_RAW("ColorSpace=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBColorSpace));
    HV_LOG_RAW("BrightRange=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBBrightRange));
    HV_LOG_RAW("BlackLevel=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBBlackLevel));
    HV_LOG_RAW("R Gain=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, usDBRGain));
    HV_LOG_RAW("G Gain=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, usDBGGain));
    HV_LOG_RAW("B Gain=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, usDBBGain));

    HV_LOG_RAW("Gamut =%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBGamut));
    HV_LOG_RAW("GCMode =%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBGcMode));
    HV_LOG_RAW("gcBlack =%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBGcBlack));

    HV_LOG_RAW("Gamma=%u\r\n", HV_COMMON_DATABASE_GET(DiagData, ucDBGammaIndex));
    return 0;
}
HV_SHELL_EXPORT_CMD(pqdata, Hv_Shell_DrvDataDebug, "Drv data debug");



int Hv_Shell_CmLutInit(int argc, char* argv[])
{
    int i = 128;
    Hv_Mw_PQ_CMSetHue(PQ_CM_R, i);
    Hv_Mw_PQ_CMSetHue(PQ_CM_G, i);
    Hv_Mw_PQ_CMSetHue(PQ_CM_B, i);
    Hv_Mw_PQ_CMSetHue(PQ_CM_C, i);
    Hv_Mw_PQ_CMSetHue(PQ_CM_M, i);
    Hv_Mw_PQ_CMSetHue(PQ_CM_Y, i);

    Hv_Mw_PQ_CMSetLum(PQ_CM_R, i);
    Hv_Mw_PQ_CMSetLum(PQ_CM_G, i);
    Hv_Mw_PQ_CMSetLum(PQ_CM_B, i);
    Hv_Mw_PQ_CMSetLum(PQ_CM_Y, i);
    Hv_Mw_PQ_CMSetLum(PQ_CM_M, i);
    Hv_Mw_PQ_CMSetLum(PQ_CM_C, i);

    Hv_Mw_PQ_CMSetSat(PQ_CM_R, i);
    Hv_Mw_PQ_CMSetSat(PQ_CM_G, i);
    Hv_Mw_PQ_CMSetSat(PQ_CM_B, i);
    Hv_Mw_PQ_CMSetSat(PQ_CM_Y, i);
    Hv_Mw_PQ_CMSetSat(PQ_CM_M, i);
    Hv_Mw_PQ_CMSetSat(PQ_CM_C, i);

    return 0;
}
HV_SHELL_EXPORT_CMD(cminit1, Hv_Shell_CmLutInit, "cminit1");



int Hv_Shell_Sharp(int argc, char* argv[])
{
    HV_LOG_RAW("sharp Setting\r\n");
    Hv_App_PQ_SharpnessInit();
    //Hv_Mw_PQ_CscInit();
    return 0;
}
HV_SHELL_EXPORT_CMD(sharpinit, Hv_Shell_Sharp, "sharp");

int Hv_Shell_Sharp1(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        HV_LOG_RAW("GAMUT Setting\r\n");
        uiValue = atoi(argv[1]);
        Hv_App_PQ_SetSharpness(uiValue);
    }
    return 0;
}

HV_SHELL_EXPORT_CMD(sharp, Hv_Shell_Sharp1, "sharp1");




int Hv_Shell_WcgInit(int argc, char* argv[])
{
    HV_LOG_RAW("WCG Setting\r\n");
    Hv_App_PQ_WcgInit();
    return 0;
}
HV_SHELL_EXPORT_CMD(wcginit, Hv_Shell_WcgInit, "wcginit");

int Hv_Shell_Gamut(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        HV_LOG_RAW("GAMUT Setting\r\n");
        uiValue = atoi(argv[1]);
        Hv_App_PQ_SetGamut(uiValue);
    }
    return 0;
}

HV_SHELL_EXPORT_CMD(gamut, Hv_Shell_Gamut, "gamut");


int Hv_Shell_PQBypass(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        uiValue = atoi(argv[1]);
        HV_LOG_RAW("PQ Bpass %d\r\n",uiValue);
        Hv_Mw_PQ_PQBypass(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(pqbypass, Hv_Shell_PQBypass, "pqbypass 0/1");


int Hv_Shell_GC(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    //if(argc == 2)
    {
        HV_LOG_RAW("GC Setting\r\n");
        //   uiValue = atoi(argv[1]);
        Hv_App_PQ_GcInit();
    }
    return 0;
}

HV_SHELL_EXPORT_CMD(gcinit, Hv_Shell_GC, "gcinit");

int Hv_Shell_GCMode(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    UINT32 uiValue1 = 0;
    if(argc == 3)
    {
        HV_LOG_RAW("GC Setting\r\n");
        uiValue = atoi(argv[1]);
        uiValue1 = atoi(argv[2]);
        Hv_Mw_PQ_GcModeSwitch(uiValue, uiValue1);
    }
    return 0;
}

HV_SHELL_EXPORT_CMD(gcmode, Hv_Shell_GCMode, "gcmode");



#if (HV_PROJECT_CONFIG_FULL_LOCALDIMMING == HV_CONFIG_ON)
int Hv_Shell_LDEnable(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        HV_LOG_RAW("ld enable\r\n");
        uiValue = atoi(argv[1]);
        //Hv_App_PQ_LdcSetMode(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(lden, Hv_Shell_LDEnable, "lden");

int Hv_Shell_LDDlcEnable(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        HV_LOG_RAW("lddlc enanle\r\n");
        uiValue = atoi(argv[1]);
        //Hv_App_PQ_LdcDynamicMaxBacklightEn(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(lddlcen, Hv_Shell_LDDlcEnable, "lddlcen");

int Hv_Shell_LDSetMaxval(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        HV_LOG_RAW("ld set max val\r\n");
        uiValue = atoi(argv[1]);
        //Hv_App_PQ_LdcSetDynamicMaxBacklight(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(ldsetmaxval, Hv_Shell_LDSetMaxval, "ldsetmaxval");

int Hv_Shell_LDSetWeight(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        HV_LOG_RAW("ld set weight val\r\n");
        uiValue = atoi(argv[1]);
        //Hv_App_PQ_LdcSetDynamicBacklightWeight(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(ldsetweight, Hv_Shell_LDSetWeight, "ldsetweight");
#endif


int Hv_LDpwm(int argc, char* argv[])
{

    UINT32 uiValue = 0;
    if(argc == 2)
    {
        HV_LOG_RAW("ld pwm\r\n");
        uiValue = atoi(argv[1]);
        Hv_Mw_PQ_LdcPwmBlend(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(ldpwm, Hv_LDpwm, "pwm");

int Hv_LDmode(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    UINT32 uiWeightValue = 0;
    if(argc == 2)
    {
        HV_LOG_RAW("ld mode\r\n");
        uiValue = atoi(argv[1]);
        Hv_Mw_PQ_LdcSetMode(uiValue, uiWeightValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(ldmode, Hv_LDmode, "ld mode");




int Hv_BrightSet(int argc, char* argv[])
{
    HV_LOG_RAW("PWM set\r\n");
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        uiValue = atoi(argv[1]);
        Hv_App_PQ_SetBrightness(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(bright, Hv_BrightSet, "bright");


int Hv_GammaSet(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if(argc == 2)
    {
        HV_LOG_RAW("Gamma Setting\r\n");
        uiValue = atoi(argv[1]);
        Hv_App_PQ_SetGamma(uiValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(gammaset, Hv_GammaSet, "gamaset");



int Hv_Shell_HDRSet(int argc, char* argv[])
{
    HV_LOG_RAW("HDR Set\r\n");
    UINT32 uiValue = 0;
    const ChannelManager* pstChannelManager = Hv_Mw_Channel_GetManager();
    const VideoConfigParams *tmp;
    tmp = &pstChannelManager->astChannelData[0].stVideoConfigParams;
    if(argc == 2)
    {
        uiValue = atoi(argv[1]);
        Hv_Mw_PQ_SetHdrMode(CHANNEL_MAIN, uiValue, (HDRParam*)&tmp->stHdrParam);
#ifdef CONFIG_USER_DOUBLE_CHANNEL_ON
        Hv_Mw_PQ_SetHdrMode(CHANNEL_SUB, uiValue, (HDRParam*)&tmp->stHdrParam);
#endif
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(hdrset, Hv_Shell_HDRSet, "hdrset");





int Hv_Shell_CscMtx(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    UINT32 uiValue1 = 0;
    UINT32 uiValue2 = 0;
    if(argc >= 3)
    {
        uiValue = atoi(argv[2]);
        if (0 == strcmp("br", argv[1]))//sat
        {
           Hv_App_PQ_SetBrightRange(uiValue);
        }
        else if(0 == strcmp("cs", argv[1]))
        {
           Hv_App_PQ_SetColorSpace(uiValue);
        }
        else if(0 == strcmp("rgb", argv[1]))
        {
           if(argc == 5)
           {
               uiValue1 = atoi(argv[3]);
               uiValue2 = atoi(argv[4]);
           }
           Hv_App_PQ_SetRGBGain(uiValue, uiValue1, uiValue2);
        }
        else if(0 == strcmp("ct", argv[1]))
        {
            Hv_App_PQ_SetContrast(uiValue);
        }
        else if(0 == strcmp("bl", argv[1]))
        {
            Hv_App_PQ_SetBlackLevel(uiValue);
        }
        else if(0 == strcmp("sa", argv[1]))
        {
            Hv_App_PQ_SetSaturation(uiValue);
        }
        //else if(0 == strcmp("sr", argv[1]))
        //{
        //    Hv_Mw_PQ_SetSharpness(uiValue);
        //}
        //else if(0 == strcmp("gcmode", argv[1]))
        //{
        //   if(argc == 4)
        //   {
        //       uiValue1 = atoi(argv[3]);
        //   }

        //    Hv_Mw_PQ_GcModeSwitch(uiValue, uiValue1);
        //}
    }
    return 0;
}

HV_SHELL_EXPORT_CMD(cscmtx, Hv_Shell_CscMtx, "cscmtx");


int Hv_Shell_FacRGB(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    UINT32 uiValue1 = 0;
    UINT32 uiValue2 = 0;

    if(argc == 4)
    {
        uiValue = atoi(argv[1]);
        uiValue1 = atoi(argv[2]);
        uiValue2 = atoi(argv[3]);
    }
    Hv_App_PQ_SetRGBGainFac(uiValue, uiValue1, uiValue2);
    return 0;
}
HV_SHELL_EXPORT_CMD(facrgb, Hv_Shell_FacRGB, "FacRGB");

#ifndef OFFSET_OF
 #define OFFSET_OF(type, member) \
    ((UINT32)(&((type *)0)->member))
#endif

int Hv_Shell_Facdbg(int argc, char* argv[])
{

    HDCPKeyDataDBRegion *pstHdcpKey = Hv_Common_Db_GetHDCPKeyDataDBRegionPtr();
    HV_LOG_INFO(HDMI, "pstHdcpKey addr %x ", (UINT32)pstHdcpKey);
    HV_LOG_INFO(HDMI, "%x %x %x %x %x ",pstHdcpKey->stHdcp1xRxKey.aucDks[0],pstHdcpKey->stHdcp1xRxKey.aucDks[1],pstHdcpKey->stHdcp1xRxKey.aucDks[2],pstHdcpKey->stHdcp1xRxKey.aucDks[3],pstHdcpKey->stHdcp1xRxKey.aucDks[4]);


    ColorTemperature stCt =  HV_COMMON_DATABASE_GET(FactoryData, stColTempStandard);
    HV_LOG_INFO(DEFAULT, "St %d %d %d", stCt.ucColorTempRGain, stCt.ucColorTempGGain,stCt.ucColorTempBGain);
    stCt =  HV_COMMON_DATABASE_GET(FactoryData, stColTempWarm);
    HV_LOG_INFO(DEFAULT, "Warm %d %d %d", stCt.ucColorTempRGain, stCt.ucColorTempGGain,stCt.ucColorTempBGain);
    stCt =  HV_COMMON_DATABASE_GET(FactoryData, stColTempCool);
    HV_LOG_INFO(DEFAULT, "Cold %d %d %d", stCt.ucColorTempRGain, stCt.ucColorTempGGain,stCt.ucColorTempBGain);
    stCt = HV_COMMON_DATABASE_GET(FactoryData, stColTempSrgb);
    HV_LOG_INFO(DEFAULT, "Temp SRGB %d %d %d", stCt.ucColorTempRGain, stCt.ucColorTempGGain, stCt.ucColorTempBGain);
    stCt = HV_COMMON_DATABASE_GET(FactoryData, stColTempEyeCare);
    HV_LOG_INFO(DEFAULT, "Temp stColTempEyeCare %d %d %d", stCt.ucColorTempRGain, stCt.ucColorTempGGain, stCt.ucColorTempBGain);
    stCt = HV_COMMON_DATABASE_GET(FactoryData, stColTempP3);
    HV_LOG_INFO(DEFAULT, "Temp P3 %d %d %d", stCt.ucColorTempRGain, stCt.ucColorTempGGain, stCt.ucColorTempBGain);
    GamutSet stGamut = HV_COMMON_DATABASE_GET(FactoryData,stGamutSrgb);
    HV_LOG_INFO(DEFAULT, "GmautSRGB %x %x %x %x %x %x %x %x %x", stGamut.usCoef_R_r, stGamut.usCoef_G_r,stGamut.usCoef_B_r,stGamut.usCoef_R_g,stGamut.usCoef_G_g,stGamut.usCoef_B_g,stGamut.usCoef_R_b,stGamut.usCoef_G_b,stGamut.usCoef_B_b);
    HV_LOG_INFO(DEFAULT, "GmautSRGB %x %x %x %x %x %x %x %x %x", stGamut.usOsdCoef_R_r, stGamut.usOsdCoef_G_r,stGamut.usOsdCoef_B_r,stGamut.usOsdCoef_R_g,stGamut.usOsdCoef_G_g,stGamut.usOsdCoef_B_g,stGamut.usOsdCoef_R_b,stGamut.usOsdCoef_G_b,stGamut.usOsdCoef_B_b);

    stGamut = HV_COMMON_DATABASE_GET(FactoryData,stGamut709);
    HV_LOG_INFO(DEFAULT, "Gmaut709 %x %x %x %x %x %x %x %x %x", stGamut.usCoef_R_r, stGamut.usCoef_G_r,stGamut.usCoef_B_r,stGamut.usCoef_R_g,stGamut.usCoef_G_g,stGamut.usCoef_B_g,stGamut.usCoef_R_b,stGamut.usCoef_G_b,stGamut.usCoef_B_b);
    HV_LOG_INFO(DEFAULT, "Gmaut709 %x %x %x %x %x %x %x %x %x", stGamut.usOsdCoef_R_r, stGamut.usOsdCoef_G_r,stGamut.usOsdCoef_B_r,stGamut.usOsdCoef_R_g,stGamut.usOsdCoef_G_g,stGamut.usOsdCoef_B_g,stGamut.usOsdCoef_R_b,stGamut.usOsdCoef_G_b,stGamut.usOsdCoef_B_b);

    stGamut = HV_COMMON_DATABASE_GET(FactoryData,stGamutP3);
    HV_LOG_INFO(DEFAULT, "GmautP3 %x %x %x %x %x %x %x %x %x", stGamut.usCoef_R_r, stGamut.usCoef_G_r,stGamut.usCoef_B_r,stGamut.usCoef_R_g,stGamut.usCoef_G_g,stGamut.usCoef_B_g,stGamut.usCoef_R_b,stGamut.usCoef_G_b,stGamut.usCoef_B_b);
    HV_LOG_INFO(DEFAULT, "GmautP3 %x %x %x %x %x %x %x %x %x", stGamut.usOsdCoef_R_r, stGamut.usOsdCoef_G_r,stGamut.usOsdCoef_B_r,stGamut.usOsdCoef_R_g,stGamut.usOsdCoef_G_g,stGamut.usOsdCoef_B_g,stGamut.usOsdCoef_R_b,stGamut.usOsdCoef_G_b,stGamut.usOsdCoef_B_b);
    
    stGamut = HV_COMMON_DATABASE_GET(FactoryData,stGamutHdr);
    HV_LOG_INFO(DEFAULT, "GmautHDR %x %x %x %x %x %x %x %x %x", stGamut.usCoef_R_r, stGamut.usCoef_G_r,stGamut.usCoef_B_r,stGamut.usCoef_R_g,stGamut.usCoef_G_g,stGamut.usCoef_B_g,stGamut.usCoef_R_b,stGamut.usCoef_G_b,stGamut.usCoef_B_b);
    HV_LOG_INFO(DEFAULT, "GmautHDR %x %x %x %x %x %x %x %x %x", stGamut.usOsdCoef_R_r, stGamut.usOsdCoef_G_r,stGamut.usOsdCoef_B_r,stGamut.usOsdCoef_R_g,stGamut.usOsdCoef_G_g,stGamut.usOsdCoef_B_g,stGamut.usOsdCoef_R_b,stGamut.usOsdCoef_G_b,stGamut.usOsdCoef_B_b);
   
    stGamut = HV_COMMON_DATABASE_GET(FactoryData,stGamutAdobe);
    HV_LOG_INFO(DEFAULT, "GmautAdobe %x %x %x %x %x %x %x %x %x", stGamut.usCoef_R_r, stGamut.usCoef_G_r,stGamut.usCoef_B_r,stGamut.usCoef_R_g,stGamut.usCoef_G_g,stGamut.usCoef_B_g,stGamut.usCoef_R_b,stGamut.usCoef_G_b,stGamut.usCoef_B_b);
    HV_LOG_INFO(DEFAULT, "GmautAdobe %x %x %x %x %x %x %x %x %x", stGamut.usOsdCoef_R_r, stGamut.usOsdCoef_G_r,stGamut.usOsdCoef_B_r,stGamut.usOsdCoef_R_g,stGamut.usOsdCoef_G_g,stGamut.usOsdCoef_B_g,stGamut.usOsdCoef_R_b,stGamut.usOsdCoef_G_b,stGamut.usOsdCoef_B_b);

    stGamut = HV_COMMON_DATABASE_GET(FactoryData,stGamutNative);
    HV_LOG_INFO(DEFAULT, "GmautNative %x %x %x %x %x %x %x %x %x", stGamut.usCoef_R_r, stGamut.usCoef_G_r,stGamut.usCoef_B_r,stGamut.usCoef_R_g,stGamut.usCoef_G_g,stGamut.usCoef_B_g,stGamut.usCoef_R_b,stGamut.usCoef_G_b,stGamut.usCoef_B_b);
    HV_LOG_INFO(DEFAULT, "GmautNative %x %x %x %x %x %x %x %x %x", stGamut.usOsdCoef_R_r, stGamut.usOsdCoef_G_r,stGamut.usOsdCoef_B_r,stGamut.usOsdCoef_R_g,stGamut.usOsdCoef_G_g,stGamut.usOsdCoef_B_g,stGamut.usOsdCoef_R_b,stGamut.usOsdCoef_G_b,stGamut.usOsdCoef_B_b);


    UCHAR8 ucTemp = 0;
    ucTemp = HV_COMMON_DATABASE_GET(FactoryData,ucFactWeek);
    HV_LOG_INFO(DEFAULT, "week %d", ucTemp);
    ucTemp = HV_COMMON_DATABASE_GET(FactoryData,ucFactYear);
    HV_LOG_INFO(DEFAULT, "Year %d", ucTemp);
    ucTemp = HV_COMMON_DATABASE_GET(FactoryData,ucFactoryBrightness);
    HV_LOG_INFO(DEFAULT, "Bright %d", ucTemp);
    ucTemp = HV_COMMON_DATABASE_GET(FactoryData,ucFactoryContrast);
    HV_LOG_INFO(DEFAULT, "BContrast %d", ucTemp);
    ucTemp = HV_COMMON_DATABASE_GET(FactoryData,ucFactorySharpness);
    HV_LOG_INFO(DEFAULT, "Sharpness %d", ucTemp);
    ucTemp = HV_COMMON_DATABASE_GET(FactoryData,ucFactoryEnergy);
    HV_LOG_INFO(DEFAULT, "Energy %d", ucTemp);
    ucTemp = HV_COMMON_DATABASE_GET(FactoryData,ucDefaultLanguage);
    HV_LOG_INFO(DEFAULT, "Language %d", ucTemp);
    ucTemp = HV_COMMON_DATABASE_GET(FactoryData,bModifyFlag);
    HV_LOG_INFO(DEFAULT, "modify %d", ucTemp);

    //ColorTemperature stCt = {0};

    ucTemp = HV_COMMON_DATABASE_GET(GammaData,bModifyFlag);
    HV_LOG_INFO(DEFAULT, "Gamma flag %x", ucTemp);
    ucTemp = HV_COMMON_DATABASE_GET(GammaData,ucGmaNum);
    HV_LOG_INFO(DEFAULT, "Gamma num %d", ucTemp);
    for(int i = 0; i < 24; i++)
    {
        ucTemp = HV_COMMON_DATABASE_GET(FactoryData,acProductSn[i]);
        HV_LOG_INFO(DEFAULT, "SN[%d] %x", i, ucTemp);
    }

    for(int i = 0; i < 13; i++)
    {
        ucTemp = HV_COMMON_DATABASE_GET(FactoryData,acDescSn[i]);
        HV_LOG_INFO(DEFAULT, "EDID SN[%d] %x", i, ucTemp);
    }

    UCHAR8 array[16] ={0};
    //Hv_Drv_Flash_ReadMonitorData(FACTORY_DATA_START_ADDRESS+OFFSET_OF(FactoryDataDBRegion, ucFactWeek), array, 16);
    Hv_Drv_Flash_ReadMonitorData(HDCP_DATA_START_ADDRESS, array, 16);
    for(int i = 0; i < 16; i++)
    {
        HV_LOG_INFO(DEFAULT, "HDCP[%d]%x", i, array[i]);
    }
    Hv_Drv_Flash_ReadMonitorData(HDCP_DATA_START_ADDRESS + 512, array, 16);
    for(int i = 0; i < 16; i++)
    {
        HV_LOG_INFO(DEFAULT, "HDCP[%d]%x", 512 + i, array[i]);
    }

    Hv_Drv_Flash_ReadMonitorData(DPEDID_DATA_START_ADDRESS, array, 16);
    for(int i = 0; i < 16; i++)
    {
        HV_LOG_INFO(DEFAULT, "DPEDID[%d]%x", i, array[i]);
    }
    Hv_Drv_Flash_ReadMonitorData(DPEDID_DATA_START_ADDRESS + 128, array, 16);
    for(int i = 0; i < 16; i++)
    {
        HV_LOG_INFO(DEFAULT, "DPEDID[%d]%x", 128 + i, array[i]);
    }

    Hv_Drv_Flash_ReadMonitorData(HDMIEDID_DATA_START_ADDRESS, array, 16);
    for(int i = 0; i < 16; i++)
    {
        HV_LOG_INFO(DEFAULT, "HDMIEDID[%d]%x", i, array[i]);
    }
    Hv_Drv_Flash_ReadMonitorData(HDMIEDID_DATA_START_ADDRESS + 128, array, 16);
    for(int i = 0; i < 16; i++)
    {
        HV_LOG_INFO(DEFAULT, "HDMIEDID[%d]%x", 128 + i, array[i]);
    }

    return 0;
}
HV_SHELL_EXPORT_CMD(facdbg, Hv_Shell_Facdbg, "Facdbg");

int Hv_Shell_Facp3(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    UINT32 uiValue1 = 0;
    UINT32 uiValue2 = 0;

    ColorTemperature sTp = {0};
    if(argc == 4)
    {
        uiValue = atoi(argv[1]);
        uiValue1 = atoi(argv[2]);
        uiValue2 = atoi(argv[3]);
        sTp.ucColorTempRGain = uiValue;
        sTp.ucColorTempGGain = uiValue1;
        sTp.ucColorTempBGain = uiValue2;
    }
    HV_LOG_RAW("P3 %d %d %d", uiValue, uiValue1, uiValue2);
    HV_COMMON_DATABASE_SET(FactoryData, stColTempP3, sTp);
    Hv_App_PQ_SetRGBGainFac(uiValue, uiValue1, uiValue2);
    return 0;
}
HV_SHELL_EXPORT_CMD(facp3, Hv_Shell_Facp3, "facp3 r g b");

int Hv_Shell_SetPos(int argc, char* argv[])
{
    INT32 iValue = 0;
    INT32 iValue1 = 0;
    const ChannelManager* pstChannelManager = Hv_Mw_Channel_GetManager();
    if(argc == 3)
    {
        iValue = atoi(argv[1]);
        iValue1 = atoi(argv[2]);
        HV_LOG_INFO(PQ , " %d %d", iValue, iValue1);
    }
     
    Hv_Mw_Video_SetMainPicPos((VideoConfigParams* )&pstChannelManager->astChannelData[0].stVideoConfigParams, iValue, iValue1);
    return 0;
}
HV_SHELL_EXPORT_CMD(setpos, Hv_Shell_SetPos, "GetPat");

int Hv_Shell_GetPat(int argc, char* argv[])
{
    UCHAR8 ucPat = 0;
    ucPat = Hv_Mw_PQ_GetPattern();
    HV_LOG_RAW("Pat %d", ucPat);
    Hv_Mw_PQ_LDCPrintPattern();
        
    return 0;
}
HV_SHELL_EXPORT_CMD(getpat, Hv_Shell_GetPat, "GetPat");

int Hv_Shell_ForceHdr(int argc, char* argv[])
{
    int uiValue = 0;
    if(argc == 2)
    {

        if (0 == strcmp("0", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, enHdrSwitch, 0);
            Hv_App_PQ_ForceSwitchHdr(0);
        } 
        else if (1 == strcmp("0", argv[1]))
        {
            HV_COMMON_DATABASE_SET(UserData, enHdrSwitch, 1);
            Hv_App_PQ_ForceSwitchHdr(1);
        }
        else
        {
            
            HV_LOG_RAW("HDR %d \r\n", HV_COMMON_DATABASE_GET(UserData, enHdrSwitch));
        }
    }
    return 0;
}

HV_SHELL_EXPORT_CMD(hdrf, Hv_Shell_ForceHdr, "hdrf");


int Hv_Shell_SetSclRatio(int argc, char* argv[])
{
    int uiValue = 0;
    if(argc == 2)
    {
        uiValue = atoi(argv[1]);
        HV_COMMON_DATABASE_SET(UserData, ucProportion, uiValue);

        HV_ASSERT_SUCCESS(SendNotifyMessageToSystemTask(SETTING_PARAM_ID_ASPECT_RATIO, uiValue));
    }
    return 0;
}

HV_SHELL_EXPORT_CMD(dpuscl, Hv_Shell_SetSclRatio, "0:(Auto) 1:(16:9) 2:(4:3), 3:(21:9), 4:(5:3),5:(1:1), 6:(16:10)  7:(5:4) 8-Max:(user define)");


extern VOID Hv_Cal_DpuScaler_SendKspiData(UCHAR8* pucData, USHORT16 usDataSize);
extern DisplayInterrupt* Hv_Mw_Video_GetDisplayInterrupt();
extern VOID Hv_Mw_Video_ClearDisplayInterrupt();
int Hv_Shell_VideoInterruptDebug(int argc, char* argv[])
{
    if (2 == argc)
    {
        if (0 == strcmp("0", argv[1]))
        {
            Hv_Mw_Video_ClearDisplayInterrupt();
        }
        else if (0 == strcmp("1", argv[1]))
        {
            DisplayInterrupt* pstDisplayInterrupt = Hv_Mw_Video_GetDisplayInterrupt();
            HV_LOG_RAW("uiInterruptCount =%u,  enInterruptType=%u .\r\n", pstDisplayInterrupt->uiInterruptCount, pstDisplayInterrupt->enInterruptType);
            Hv_Vos_MSleep(1000);
            HV_LOG_RAW("uiInterruptCount =%u, enInterruptType=%u.\r\n", pstDisplayInterrupt->uiInterruptCount, pstDisplayInterrupt->enInterruptType);
        }
        else if (0 == strcmp("2", argv[1]))
        {
            Hv_Cal_DpuScaler_SendKspiData(NULL, 1001);
            HV_LOG_RAW("Hv_Cal_DpuScaler_SendKspiData()\r\n");
        }
    }
    return HV_SUCCESS;
}
HV_SHELL_EXPORT_CMD(video_interrupt_debug, Hv_Shell_VideoInterruptDebug, "0:clear count 1:show 1s count  2:kspi send test");

#define VIDEO_DEBUG_SET_PARAM(paramId, userDataMember, middlewareFunctin, uiValue) \
case paramId:\
{\
    HV_COMMON_DATABASE_SET(UserData, userDataMember, uiValue);\
    middlewareFunctin(uiValue);\
    break;\
}

int Hv_Shell_VideoDebug(int argc, char* argv[])
{
    if (1 == argc)
    {
        const PanelParam stPanelParam = Hv_Mw_Panel_GetCurrentPanelParam();
        HV_LOG_RAW("SETTING_PARAM_ID_BRIGHTNESS id=%u value:0-100", SETTING_PARAM_ID_BRIGHTNESS);
        HV_LOG_RAW("SETTING_PARAM_ID_CONTRAST id=%u  value:0-100", SETTING_PARAM_ID_CONTRAST);
        HV_LOG_RAW("SETTING_PARAM_ID_SHARPNESS=%u  value:0-100", SETTING_PARAM_ID_SHARPNESS);
        HV_LOG_RAW("SETTING_PARAM_ID_COLOR_TEMPERATURE id=%u  value:0-100", SETTING_PARAM_ID_COLOR_TEMPERATURE);
        HV_LOG_RAW("SettingParamId_HdrEnable id=%u  value:0-disable 1-enable 2-force", SETTING_PARAM_ID_HDR_SWITCH);
        HV_LOG_RAW("SETTING_PARAM_ID_ASPECT_RATIO id=%u value: 0-(16:9) 1-(4:3) 2-(auto)", SETTING_PARAM_ID_ASPECT_RATIO);
        HV_LOG_RAW("SETTING_PARAM_ID_PXP_CONFIG id=%u value: 0-close PXP 1-open pip 2-open PBP", SETTING_PARAM_ID_PXP_CONFIG);
        HV_LOG_RAW("SETTING_PARAM_ID_HDMI_VER id=%u value: 0-1", SETTING_PARAM_ID_HDMI_VER);
        HV_LOG_RAW("SETTING_PARAM_ID_DP_VER id=%u ", SETTING_PARAM_ID_DP_VER);
        HV_LOG_RAW("SETTING_PARAM_ID_MAIN_SOURCE id=%u value: 0-hdmi0 1-hdmi1 2-DP0 3-DP1", SETTING_PARAM_ID_MAIN_SOURCE);
        HV_LOG_RAW("SETTING_PARAM_ID_SUB_SOURCE id=%u value: 0-hdmi0 1-hdmi1 2-DP0 3-DP1", SETTING_PARAM_ID_SUB_SOURCE);
        HV_LOG_RAW("SETTING_PARAM_ID_MAIN_OR_SUB_SOURCE_SWAP id=%u", SETTING_PARAM_ID_MAIN_OR_SUB_SOURCE_SWAP);
        HV_LOG_RAW("SETTING_PARAM_ID_PIP_SUB_WINDOW_POSITION_RECONFIG id=%u value:0-left up 1-left down 2:right up 3-right down", SETTING_PARAM_ID_PIP_SUB_WINDOW_POSITION_RECONFIG);
        HV_LOG_RAW("SETTING_PARAM_ID_PIP_SUB_WINDOW_SIZE_RECONFIG id=%u value:0-small 1:big", SETTING_PARAM_ID_PIP_SUB_WINDOW_SIZE_RECONFIG);
        HV_LOG_RAW("SETTING_PARAM_ID_PXP_AUDIO_SOURCE id=%u value: 0-MainChannel/Left 1:SubChannel/Right", SETTING_PARAM_ID_PXP_AUDIO_SOURCE);
        HV_LOG_RAW("pip h pos 1 pixel shift id=70 value:H(0-3840)");
        HV_LOG_RAW("pip v pos 1 pixel shift id=71 value:V(0-2160)");
        HV_LOG_RAW("SETTING_PARAM_ID_VOLUME id=%u value:0-100", SETTING_PARAM_ID_VOLUME);
        HV_LOG_RAW("SETTING_PARAM_ID_FREE_SYNC_SWITCH id=%u value:0-1", SETTING_PARAM_ID_FREE_SYNC_SWITCH);
        HV_LOG_RAW("SETTING_PARAM_ID_DATA_PATH_RECONFIG id=%u value:0", SETTING_PARAM_ID_DATA_PATH_RECONFIG);
        HV_LOG_RAW("SETTING_PARAM_ID_VIDEO_AUTO_SELECT_SOURCE_SWITCH id=%u ", SETTING_PARAM_ID_VIDEO_AUTO_SELECT_SOURCE_SWITCH);
        HV_LOG_RAW("SETTING_PARAM_ID_MAGNIFY_GLASS_SWITCH id=%u   value:0-1", SETTING_PARAM_ID_MAGNIFY_GLASS_SWITCH);
        HV_LOG_RAW("SETTING_PARAM_ID_MAGNIFY_GLASS_SET_RATIO id=%u value:0-100", SETTING_PARAM_ID_MAGNIFY_GLASS_SET_RATIO);
        HV_LOG_RAW("SETTING_PARAM_ID_MAGNIFY_GLASS_SET_POS id=%u  value:H(0-3840) V(0-2160)", SETTING_PARAM_ID_MAGNIFY_GLASS_SET_POS);
        HV_LOG_RAW("SETTING_PARAM_ID_MAGNIFY_GLASS_SET_SIZE id=%u value:H(1-1920) V(1-1080)", SETTING_PARAM_ID_MAGNIFY_GLASS_SET_SIZE);
        HV_LOG_RAW("set magnify sampling location id=62 value:H(0-3840) V(0-2160)");
        HV_LOG_RAW("SETTING_PARAM_ID_VIDEO_HFLIP id=%u value:0-disable 1:enable", SETTING_PARAM_ID_VIDEO_HFLIP);
        HV_LOG_RAW("SETTING_PARAM_ID_VIDEO_VFLIP id=%u value:0-disable 1:enable", SETTING_PARAM_ID_VIDEO_VFLIP);
        HV_LOG_RAW("SETTING_PARAM_ID_AUTO_UPDATE_EDID_WHILE_SEARCH_SRC id=%u value:0-disable 1:enable", SETTING_PARAM_ID_AUTO_UPDATE_EDID_WHILE_SEARCH_SRC);
        HV_LOG_RAW("SETTING_PARAM_ID_INP_PATTERN_FRAME_RATE id=%u frame rate min:%u max:%u", SETTING_PARAM_ID_INP_PATTERN_FRAME_RATE, stPanelParam.usPanelFrameRateMin, stPanelParam.usPanelFrameRateMax);
        HV_LOG_RAW("SETTING_PARAM_ID_MAIN_MONTAGE id=%u montage enable:1 disable:0", SETTING_PARAM_ID_MAIN_MONTAGE);
        HV_LOG_RAW("set montage postion and size. id=61 hsta hend vsta vend");
        HV_LOG_RAW("SETTING_PARAM_ID_MAIN_OVER_SCAN. id=47 OverScan enable");
        HV_LOG_RAW("SETTING_PARAM_ID_BRIGHT_FRAME. id=48 1:en, 2:size, 3:h pos, 4:v pos");
        HV_LOG_RAW("SETTING_PARAM_ID_PRO_ESPORT_SWITCH. id=49 1:en, 0:disable\r\n");
    }
    if (3 == argc)
    {
        UINT32 uiSettngParamId = atoi(argv[1]);
        UINT32 uiValue = atoi(argv[2]);
        switch (uiSettngParamId)
        {
            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_BRIGHTNESS, ucBrightness, Hv_App_PQ_SetBrightness, uiValue)
            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_CONTRAST, ucContrast, Hv_App_PQ_SetContrast, uiValue)
            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_SHARPNESS, ucSharpness, Hv_App_PQ_SetSharpness, uiValue)
            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_HDR_SWITCH, enHdrSwitch, Hv_App_PQ_SetHdrSwitch, uiValue)
            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_ASPECT_RATIO, ucProportion, Hv_Mw_Video_SetAspectRatio, uiValue)
#ifdef CONFIG_USER_DOUBLE_CHANNEL_ON
            case SETTING_PARAM_ID_PXP_CONFIG:
            {
                Hv_Mw_Video_SetPxpMode(uiValue);
                break;
            }
            //VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_PXP_CONFIG, ucPxPMode, Hv_Mw_Video_SetPxpMode, uiValue)
            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_SUB_SOURCE, ucPxPVideoSource, Hv_Mw_Video_SetSubVideoSource, uiValue)
            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_PIP_SUB_WINDOW_POSITION_RECONFIG, ucPipPosition, Hv_Mw_Video_SetSubVideoWindowPosition, uiValue)
            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_PIP_SUB_WINDOW_SIZE_RECONFIG, ucPipSize, Hv_Mw_Video_SetSubVideoWindowSize, uiValue)
#endif
            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_PXP_AUDIO_SOURCE, ucAudioSource, Hv_Mw_Channel_AudioSourceConfig, uiValue)
            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_MAIN_SOURCE, ucVideoSource, Hv_Mw_Video_SetMainVideoSource, uiValue)            

            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_FREE_SYNC_SWITCH, ucFreeSync, Hv_Mw_Video_SetFreeSyncSwitch, uiValue)
            VIDEO_DEBUG_SET_PARAM(SETTING_PARAM_ID_VIDEO_AUTO_SELECT_SOURCE_SWITCH, bAutoVideoSrcSelSw, Hv_Mw_Video_SetVideoAutoSelectSw, uiValue)

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY) 
            case SETTING_PARAM_ID_MAGNIFY_GLASS_SWITCH:
            {
                Hv_Mw_Video_SetMagnifyGlassSwitch(uiValue);
                break;
            }
            case SETTING_PARAM_ID_MAGNIFY_GLASS_SET_RATIO:
            {
                //TODO: 命令行不支持浮点输入
                HV_COMMON_DATABASE_SET(UserData, fMagnifyGlassScalerUpRatio, uiValue);
                Hv_Mw_Video_SetMagnifyGlassRatio(uiValue);
                break;
            }
#endif
            case SETTING_PARAM_ID_VIDEO_HFLIP:
            {
                HV_COMMON_DATABASE_SET(DiagData, stDisplayDebug.bHflipEnable, uiValue);
                Hv_Mw_Video_SetHflipSwitch(uiValue);
                break;
            }
            case SETTING_PARAM_ID_VIDEO_VFLIP:
            {
                HV_COMMON_DATABASE_SET(DiagData, stDisplayDebug.bVflipEnable, uiValue);
                Hv_Mw_Video_SetVflipSwitch(uiValue);
                break;
            }
            case SETTING_PARAM_ID_AUTO_UPDATE_EDID_WHILE_SEARCH_SRC:
            {
                HV_COMMON_DATABASE_SET(SystemData, ucAutoUpdataEdidEnable, uiValue);
                break;
            }
#ifdef CONFIG_USER_DOUBLE_CHANNEL_ON
            case SETTING_PARAM_ID_MAIN_OR_SUB_SOURCE_SWAP:
            {
                UCHAR8  ucMainSrc = HV_COMMON_DATABASE_GET(UserData, ucVideoSource);
                UCHAR8  ucSubSrc = HV_COMMON_DATABASE_GET(UserData, ucPxPVideoSource);
                HV_COMMON_DATABASE_SET(UserData, ucVideoSource, ucSubSrc);
                HV_COMMON_DATABASE_SET(UserData, ucPxPVideoSource, ucMainSrc);
                Hv_Mw_Video_SetMainSubVideoSourceSwap();
                break;
            }
            case 70:
            {
                USHORT16 usHPosLevel = (USHORT16)uiValue;
                Hv_Mw_Video_SetPipWindowHPosition(usHPosLevel);
                break;
            }
            case 71:
            {
                USHORT16 usVPosLevel = (USHORT16)uiValue;
                Hv_Mw_Video_SetPipWindowVPosition(usVPosLevel);
                break;
            }
            case 80:
            {
                Hv_Mw_Video_SetPbpSize(uiValue);
                break;
            }
#endif
            case SETTING_PARAM_ID_INP_PATTERN_FRAME_RATE:
            {
                Hv_Mw_Video_SetPqCalibrateFrameRate(uiValue);
                break;
            }
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAIN_MONTAGE)
            case SETTING_PARAM_ID_MAIN_MONTAGE:
            {
                BOOL bSw = (BOOL)uiValue;
                Hv_Mw_Video_SetMainMontageSw(bSw);
                break;
            }
#endif
#if (0 != HV_PROJECT_CONFIG_DPU_OVER_SCAN_SIDE_SIZE)
            case SETTING_PARAM_ID_MAIN_OVER_SCAN:
            {
                BOOL bSw = (BOOL)uiValue;
                HV_COMMON_DATABASE_SET(UserData, bOverScan, bSw);
                Hv_Mw_Video_DataPathReconfig();
                break;
            }
#endif
            case SETTING_PARAM_ID_PRO_ESPORT_SWITCH:
            {
                BOOL bSw = (BOOL)uiValue;
                Hv_Mw_Video_SetProEsportSwitch(bSw);
                break;
            }
            default:
            {
                break;
            }
        }
    }

    else if (argc == 4)
    {
        UINT32 uiSettngParamId = atoi(argv[1]);
        UINT32 uiValue1 = atoi(argv[2]);
        UINT32 uiValue2 = atoi(argv[3]);
        switch (uiSettngParamId)
        {
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAGNIFY) 
            case SETTING_PARAM_ID_MAGNIFY_GLASS_SET_POS:
            {
                Hv_Mw_Video_SetMagnifyGlassPos((USHORT16)uiValue1, (USHORT16)uiValue2);
                break;
            }
            case SETTING_PARAM_ID_MAGNIFY_GLASS_SET_SIZE:
            {
                Hv_Mw_Video_SetMagnifyGlassSize((USHORT16)uiValue1, (USHORT16)uiValue2);
                break;
            }
            case 62:
            {
                Hv_Mw_Video_SetMagnifyGlassSamplingLocation((USHORT16)uiValue1, (USHORT16)uiValue2);
                break;
            }
#endif
#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_DPU_BRIGHT_FRAME)
            case SETTING_PARAM_ID_BRIGHT_FRAME:
            {
                if (1 == uiValue1)              // 1：bright frame en
                {
                    Hv_Mw_DCW_SetBrightFrameEn(uiValue2);
                }
                else if (2 == uiValue1)         // 2: bright frame size level
                {
                    Hv_Mw_DCW_SetBrightFrameSize(uiValue2);
                }
                else if (3 == uiValue1)         // 3: bright frame h pos level
                {
                    Hv_Mw_DCW_SetBrightFrameHPos(uiValue2);
                }
                else if (4 == uiValue1)         // 4: bright frame v pos level
                {
                    Hv_Mw_DCW_SetBrightFrameVPos(uiValue2);
                }
                break;
            }
#endif
            default:
            {
                break;
            }
        }
    }

#if (HV_CONFIG_ON == HV_PROJECT_CONFIG_MAIN_MONTAGE)
    else if (argc == 6)
    {
        //UINT32 uiSettngParamId = atoi(argv[1]);
        USHORT16 usCutHsta = atoi(argv[2]);
        USHORT16 usCutHend = atoi(argv[3]);;
        USHORT16 usCutVsta = atoi(argv[4]);;
        USHORT16 usCutVend = atoi(argv[5]);;
        Hv_Mw_Video_SetMainMontageParam(usCutHsta, usCutHend, usCutVsta, usCutVend);
    }
#endif
    return 0;
}
HV_SHELL_EXPORT_CMD(video_debug, Hv_Shell_VideoDebug, "input none param:show command information, two Param:Param1: 1-id 2-value");


/***************************************************************************************************/
/*************************************DPU part end ***********************************************/
/***************************************************************************************************/


/***************************************************************************************************/
/*************************************memparser start***********************************************/
/***************************************************************************************************/
#ifdef HV_CONFIG_CHIP_HT7315
void Hv_Shell_pq_table(int argc, char *argv[])
{
    int iAddr = 0;
    int iSize = 0;
    int iStatus = 0;

    SHELL_TypeDef *shell = shellGetCurrent();
    if (!shell)
    {
        return;
    }
    if (argc < 3)
    {
        HV_LOG_RAW("format: pq_table [type] [index]\r\n");
        Hv_Pq_ShowTable();
        return;
    }

    iStatus =  Hv_Pq_GetTable(atoi(argv[1]), atoi(argv[2]), &iAddr, &iSize);

    HV_LOG_RAW("status: %x\r\n", iStatus);
    HV_LOG_RAW("iAddr: %x\r\n", iAddr);
    HV_LOG_RAW("iSize: %x\r\n", iSize);
    shellDisplay(shell, "\r\n");
}
HV_SHELL_EXPORT_CMD(pq_table, Hv_Shell_pq_table, get pq table info);
#endif
void Hv_Shell_GetCodeVersion(int argc, char *argv[])
{
    int iVersion = 0;

    SHELL_TypeDef *shell = shellGetCurrent();
    if (!shell)
    {
        return;
    }
    iVersion = Hv_Comm_GetCodeVersion();

    HV_LOG_RAW("version: %8x\r\n", iVersion);
    shellDisplay(shell, "\r\n");
}
HV_SHELL_EXPORT_CMD(get_code_version, Hv_Shell_GetCodeVersion, get code version);

void Hv_Shell_ShowSuperblock(int argc, char *argv[])
{
    int iData = 0;
    int iIndex = 0;
    char aucArray[32] = {0};

    SHELL_TypeDef *shell = shellGetCurrent();
    if (!shell)
    {
        return;
    }
    while (iIndex < 0x1000)
    {
        Hv_Drv_Flash_OnlyRead((HV_FLASH_CONFIG_SUPERBLOCK_START+iIndex), aucArray, 32);
        /* chech magic number */
        if (aucArray[0] != 0x53)
        {
            break;
        }
        if (aucArray[1] != 0x42)
        {
            break;
        }
        if (aucArray[2] != 0x4c)
        {
            break;
        }
        if (aucArray[3] != 0x4b)
        {
            break;
        }
        HV_LOG_RAW("PART: %x\r\n", aucArray[7]);
        iData  = aucArray[8] << 24;
        iData |= aucArray[9] << 16;
        iData |= aucArray[10] << 8;
        iData |= aucArray[11] << 0;
        HV_LOG_RAW("SIZE: %8x\r\n", iData);
        iData  = aucArray[12] << 24;
        iData |= aucArray[13] << 16;
        iData |= aucArray[14] << 8;
        iData |= aucArray[15] << 0;
        HV_LOG_RAW("POS: %8x\r\n", iData);
        iData  = aucArray[28] << 24;
        iData |= aucArray[29] << 16;
        iData |= aucArray[30] << 8;
        iData |= aucArray[31] << 0;
        HV_LOG_RAW("CRC: %8x\r\n", iData);
        iIndex += 32;
    }

    shellDisplay(shell, "\r\n");
}
HV_SHELL_EXPORT_CMD(show_superblock, Hv_Shell_ShowSuperblock, show superblock);
/***************************************************************************************************/
/*************************************memparser end     ********************************************/
/***************************************************************************************************/



/***************************************************************************************************/
/*************************************HDMI part start ***********************************************/
/***************************************************************************************************/
extern int Hv_Shell_HdmiRxDebug(int argc, char* argv[]);

HV_SHELL_EXPORT_CMD(hdmidebug, Hv_Shell_HdmiRxDebug, "hdmidebug command line");

/***************************************************************************************************/
/*************************************HDMI part end ***********************************************/
/***************************************************************************************************/
extern int Hv_Shell_Hdcp_RxDebug(int argc, char* argv[]);

HV_SHELL_EXPORT_CMD(hdcpdebug, Hv_Shell_Hdcp_RxDebug, "hdcpdebug command line");

/***************************************************************************************************/
/*************************************DP part end **************************************************/
/***************************************************************************************************/
extern INT32 Hv_Shell_DpRx_Debug(INT32 iArgc, CHAR8 *cArgv[]);

HV_SHELL_EXPORT_CMD(dp, Hv_Shell_DpRx_Debug, "dp info/edid/hpd");

/***************************************************************************************************/
/*************************************DP part end **************************************************/
/***************************************************************************************************/


/***************************************************************************************************/
/************************************** osd part start *********************************************/
/***************************************************************************************************/
extern int Hv_Shell_SetOsdCmd(int argc, char* argv[]);
HV_SHELL_EXPORT_CMD(osd, Hv_Shell_SetOsdCmd, "osd");

/***************************************************************************************************/
/*************************************** osd part end **********************************************/
/***************************************************************************************************/


/***************************************************************************************************/
/*************************************KTX part start ***********************************************/
/***************************************************************************************************/

#if 0
/*mprt mode3 输出与vs无法的pwm，配合Hv_Drv_LowRateLEDTestInit() */
extern USHORT16 g_MprtPwmRateCase;
extern USHORT16 g_MprtDuty;
int Hv_Shell_SetMprtPwmRateCaset(int argc, char* argv[])
{
    /*输入参数数量*/
    if (1 == argc)
    {
        HV_LOG_RAW("MPRT PWM rate=%d \r\n", g_MprtPwmRateCase);
        HV_LOG_RAW("MPRT PWM duty=%d \r\n", g_MprtDuty);
    }
    if (3 == argc)
    {
        if (strcmp("r", argv[1]) == 0)
        {
            g_MprtPwmRateCase = atoi(argv[2]);
            Hv_Drv_MPRT_SwitchPwmRateCase();
        }
        else if (strcmp("d", argv[1]) == 0)
        {
            g_MprtDuty = atoi(argv[2]);
            Hv_Drv_MPRT_SwitchPwmRateCase();
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(mprt_rate_case, Hv_Shell_SetMprtPwmRateCaset, r:set rate(10,20,30...240) d:set duty(0-100));
#endif

#if 0
/* OLED 调节背光亮度 */
extern UCHAR8 g_ucOledBacklightLsb;
extern UCHAR8 g_ucOledBacklightMsb;
int Hv_Shell_SetOledPanelBacklight(int argc, char* argv[])
{
    /*输入参数数量*/
    if (1 == argc)
    {
        HV_LOG_RAW("OLED Balcklight LSB = %x \r\n", g_ucOledBacklightLsb);
        HV_LOG_RAW("OLED Balcklight MSB = %x \r\n", g_ucOledBacklightMsb);
    }
    if (3 == argc)
    {
        if (strcmp("l", argv[1]) == 0)
        {
            g_ucOledBacklightLsb = atoi(argv[2]);
            Hv_Drv_EDP_SetOledBacklight();
        }
        else if (strcmp("m", argv[1]) == 0)
        {
            g_ucOledBacklightMsb = atoi(argv[2]);
            Hv_Drv_EDP_SetOledBacklight();
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(oled_backlight, Hv_Shell_SetOledPanelBacklight, "none prarm:show backlight value; l: LSB; M: MSB");
#endif
/***************************************************************************************************/
/*************************************KTX part end *************************************************/
/***************************************************************************************************/

/***************************************************************************************************/
/*************************************factory part start *******************************************/
/***************************************************************************************************/

int Hv_Shell_FactoryDebug(int argc, char* argv[])
{
    const PanelManager* pstPanelManager = Hv_Mw_Panel_GetManagerPtr();
    const PowerManager *pstPowerManager = Hv_Mw_Power_GetManagerPtr();
    USHORT16 usPanelOnTimeHour = 0;
    USHORT16 ucPanelOnTimeMin = 0;
    /*输入参数数量*/
    if (1 == argc)
    {
        HV_LOG_RAW("1 set factory switch(1:enable, 0:disable)");
        HV_LOG_RAW("2 set burn in enable(1:enable, 0:disable)");
        HV_LOG_RAW("3 DyanmicPanelEn(1:enable, 0:disable)");
        HV_LOG_RAW("4 PanelIndex(0-4)");
        HV_LOG_RAW("5 Panel blacklight timer accelerated testing(1:start, 2: clear)\r\n");

        HV_LOG_RAW("Power Manager state:%u", pstPowerManager->enCurrentPowerState);
        HV_LOG_RAW("Panel Manager state:%u \r\n", pstPanelManager->enCurrentPanelState);

        Hv_Mw_Factory_GetPanelOnTime(&usPanelOnTimeHour, &ucPanelOnTimeMin);
        HV_LOG_RAW("bAutoVideoSrcSelSw:     %u", HV_COMMON_DATABASE_GET(UserData, bAutoVideoSrcSelSw));
        HV_LOG_RAW("ucVideoSource:          %u", HV_COMMON_DATABASE_GET(UserData, ucVideoSource));
#ifdef CONFIG_USER_DOUBLE_CHANNEL_ON
        HV_LOG_RAW("ucPxPMode:              %u", HV_COMMON_DATABASE_GET(UserData, ucPxPMode));
        HV_LOG_RAW("ucPxPVideoSource:       %u", HV_COMMON_DATABASE_GET(UserData, ucPxPVideoSource));
#endif
        HV_LOG_RAW("Factory Monitor Mode:   %s", HV_PROJECT_CONFIG_FACTORY_MONITOR_MODE);
        HV_LOG_RAW("Factory Scaler Mode:    %s", HV_PROJECT_CONFIG_FACTORY_SCALER_MODE);
        HV_LOG_RAW("Factory Fw Version:     %s", HV_PROJECT_CONFIG_FACTORY_FW_VERSION);
        HV_LOG_RAW("Factory Fw Change Date: %s", HV_PROJECT_CONFIG_FACTORY_FW_CHANGE_DATE);
        HV_LOG_RAW("Factory Panel Type:     %s", HV_PROJECT_CONFIG_FACTORY_PANEL_TYPE);
        HV_LOG_RAW("Factory Panel Size:     %s", HV_PROJECT_CONFIG_FACTORY_PANEL_SIZE);
        HV_LOG_RAW("Factory Panel On Min:   %d", ucPanelOnTimeMin);
        HV_LOG_RAW("Factory Panel On Hour:  %d", usPanelOnTimeHour);
        HV_LOG_RAW("Factory Mode:           %u", HV_COMMON_DATABASE_GET(SystemData, bFactoryMode));
        HV_LOG_RAW("Factory BurnIn:         %u", HV_COMMON_DATABASE_GET(SystemData, bBurnInEnable));
        HV_LOG_RAW("Factory DynPanel En:    %d", HV_COMMON_DATABASE_GET(FactoryData, bDynamicPanelEn));
        HV_LOG_RAW("Factory DynPanel Index: %d\r\n", HV_COMMON_DATABASE_GET(FactoryData, ucDynamicPanelIndex));
    }
    else if (3 == argc)
    {
        UINT32 uiSettngParamId = atoi(argv[1]);
        UINT32 uiValue = atoi(argv[2]);
        switch (uiSettngParamId)
        {
        case 1:         /*bFactoryMode*/
        {
            HV_COMMON_DATABASE_SET(SystemData, bFactoryMode, uiValue);
            break;
        }
        case 2:         /*bBurnInEnable*/
        {
            HV_COMMON_DATABASE_SET(SystemData, bBurnInEnable, uiValue);
            break;
        }
        case 3:         /*DyanmicPanelEn*/
        {
            HV_COMMON_DATABASE_SET(FactoryData, bDynamicPanelEn, uiValue);
            break;
        }
        case 4:         /*ucDynamicPanelIndex*/
        {
            HV_COMMON_DATABASE_SET(FactoryData, ucDynamicPanelIndex, uiValue);
            break;
        }
        case 5:         /*Panel blacklight timer accelerated testing*/
        {
            if (1 == uiValue)
            {
                for (UINT32 i = 0; i < 48185200; i++)
                {
                    Hv_Mw_Factory_SavePanelOnCountTime(HV_FALSE);
                    if(i % 7200 == 0)
                    {
                        Hv_Mw_Factory_GetPanelOnTime(&usPanelOnTimeHour, &ucPanelOnTimeMin);
                        HV_LOG_RAW("Current Hour:%u, Min:%u", usPanelOnTimeHour, ucPanelOnTimeMin);
                    }
                }
            }
            else if (2 == uiValue)
            {
                Hv_Mw_Factory_ResetPanelOnCountTime();
                Hv_Mw_Factory_GetPanelOnTime(&usPanelOnTimeHour, &ucPanelOnTimeMin);
                HV_LOG_RAW("Current Hour:%u, Min:%u", usPanelOnTimeHour, ucPanelOnTimeMin);
            }
            break;
        }
        default:
            break;
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(factory_debug, Hv_Shell_FactoryDebug, "None: Show factory Info. 1~ set factory settings.");

/* debug panel param */
int Hv_Shell_PanelParamDebug(int argc, char* argv[])
{
    PanelParam stPanelParam = {0};
    /*输入参数数量*/
    if (2 == argc)
    {
        UINT32 uiSettngParamId = atoi(argv[1]);
        PanelDataDBRegion *pstPanelDB = Hv_Common_Db_GetPanelDataDBRegionPtr();
        stPanelParam = pstPanelDB->stPanelParam[uiSettngParamId];
    }
    if (1 == argc)
    {
        stPanelParam = Hv_Mw_Panel_GetCurrentPanelParam();
    }
    HV_LOG_RAW("ucPanelName:             %s ", stPanelParam.ucPanelName);
    HV_LOG_RAW("usPanelHtotalType:       %u ", stPanelParam.usPanelHtotalType);
    HV_LOG_RAW("usPanelHtotalMax:        %u ", stPanelParam.usPanelHtotalMax);
    HV_LOG_RAW("usPanelHtotalMin:        %u ", stPanelParam.usPanelHtotalMin);
    HV_LOG_RAW("usPanelVtotalType:       %u ", stPanelParam.usPanelVtotalType);
    HV_LOG_RAW("usPanelVtotalMax:        %u ", stPanelParam.usPanelVtotalMax);
    HV_LOG_RAW("usPanelVtotalMin:        %u ", stPanelParam.usPanelVtotalMin);
    HV_LOG_RAW("usPanelHactive:          %u ", stPanelParam.usPanelHactive);
    HV_LOG_RAW("usPanelVactive:          %u ", stPanelParam.usPanelVactive);
    HV_LOG_RAW("usPanelFrameRateType:    %u ", stPanelParam.usPanelFrameRateType);
    HV_LOG_RAW("usPanelFrameRateMax:     %u ", stPanelParam.usPanelFrameRateMax);
    HV_LOG_RAW("usPanelFrameRateMin:     %u ", stPanelParam.usPanelFrameRateMin);
    HV_LOG_RAW("ucPanelHsyncWidth:       %u ", stPanelParam.ucPanelHsyncWidth);
    HV_LOG_RAW("ucPanelVsyncWidth:       %u ", stPanelParam.ucPanelVsyncWidth);
    HV_LOG_RAW("ucPanelHsyncBackPorch:   %u ", stPanelParam.ucPanelHsyncBackPorch);
    HV_LOG_RAW("ucPanelVsyncBackPorch:   %u ", stPanelParam.ucPanelVsyncBackPorch);
    HV_LOG_RAW("ucPanelColorDepth:       %u ", stPanelParam.ucPanelColorDepth);
    HV_LOG_RAW("ucPanelLaneNum:          %u ", stPanelParam.ucPanelLaneNum);
    HV_LOG_RAW("ucPanelPortNum:          %u ", stPanelParam.ucPanelPortNum);
    HV_LOG_RAW("ucPanelLaneRate:         %u ", stPanelParam.ucPanelLaneRate);
    HV_LOG_RAW("uiPanelPixelClockType:   %u ", stPanelParam.uiPanelPixelClockType);
    HV_LOG_RAW("uiPanelPixelClockMax:    %u ", stPanelParam.uiPanelPixelClockMax);
    HV_LOG_RAW("uiPanelPixelClockMin:    %u ", stPanelParam.uiPanelPixelClockMin);
    HV_LOG_RAW("usPanelPowerOnTime:      %u ", stPanelParam.usPanelPowerOnTime);
    HV_LOG_RAW("usPanelDataOnTime:       %u ", stPanelParam.usPanelDataOnTime);
    HV_LOG_RAW("usPanelBlkOnTime:        %u ", stPanelParam.usPanelBlkOnTime);
    HV_LOG_RAW("usPanelBlkOffTime:       %u ", stPanelParam.usPanelBlkOffTime);
    HV_LOG_RAW("usPanelDataOfTime:       %u ", stPanelParam.usPanelDataOfTime);
    HV_LOG_RAW("usPanelPowerOffTime:     %u ", stPanelParam.usPanelPowerOffTime);
    HV_LOG_RAW("usPanelPllLockTime:      %u ", stPanelParam.usPanelPllLockTime);
    HV_LOG_RAW("bPanelEdpAux0PnSwapEn:   %u ", stPanelParam.bPanelEdpAux0PnSwapEn);
    HV_LOG_RAW("bPanelEdpAux1PnSwapEn:   %u ", stPanelParam.bPanelEdpAux1PnSwapEn);
    HV_LOG_RAW("bPanelPhy0MuxEn:         %u ", stPanelParam.bPanelPhy0MuxEn);
    HV_LOG_RAW("ucPanelPhy0Lane0MuxSel:  %u ", stPanelParam.ucPanelPhy0Lane0MuxSel);
    HV_LOG_RAW("ucPanelPhy0Lane1MuxSel:  %u ", stPanelParam.ucPanelPhy0Lane1MuxSel);
    HV_LOG_RAW("ucPanelPhy0Lane2MuxSel:  %u ", stPanelParam.ucPanelPhy0Lane2MuxSel);
    HV_LOG_RAW("ucPanelPhy0Lane3MuxSel:  %u ", stPanelParam.ucPanelPhy0Lane3MuxSel);
    HV_LOG_RAW("bPanelPhy0Lane0PnSwap:   %u ", stPanelParam.bPanelPhy0Lane0PnSwap);
    HV_LOG_RAW("bPanelPhy0Lane1PnSwap:   %u ", stPanelParam.bPanelPhy0Lane1PnSwap);
    HV_LOG_RAW("bPanelPhy0Lane2PnSwap:   %u ", stPanelParam.bPanelPhy0Lane2PnSwap);
    HV_LOG_RAW("bPanelPhy0Lane3PnSwap:   %u ", stPanelParam.bPanelPhy0Lane3PnSwap);
    HV_LOG_RAW("bPanelPhy1MuxEn:         %u ", stPanelParam.bPanelPhy1MuxEn);
    HV_LOG_RAW("ucPanelPhy1Lane0MuxSel:  %u ", stPanelParam.ucPanelPhy1Lane0MuxSel);
    HV_LOG_RAW("ucPanelPhy1Lane1MuxSel:  %u ", stPanelParam.ucPanelPhy1Lane1MuxSel);
    HV_LOG_RAW("ucPanelPhy1Lane2MuxSel:  %u ", stPanelParam.ucPanelPhy1Lane2MuxSel);
    HV_LOG_RAW("ucPanelPhy1Lane3MuxSel:  %u ", stPanelParam.ucPanelPhy1Lane3MuxSel);
    HV_LOG_RAW("bPanelPhy1Lane0PnSwap:   %u ", stPanelParam.bPanelPhy1Lane0PnSwap);
    HV_LOG_RAW("bPanelPhy1Lane1PnSwap:   %u ", stPanelParam.bPanelPhy1Lane1PnSwap);
    HV_LOG_RAW("bPanelPhy1Lane2PnSwap:   %u ", stPanelParam.bPanelPhy1Lane2PnSwap);
    HV_LOG_RAW("bPanelPhy1Lane3PnSwap:   %u ", stPanelParam.bPanelPhy1Lane3PnSwap);
    HV_LOG_RAW("bPanelPhy2MuxEn:         %u ", stPanelParam.bPanelPhy2MuxEn);
    HV_LOG_RAW("ucPanelPhy2Lane0MuxSel:  %u ", stPanelParam.ucPanelPhy2Lane0MuxSel);
    HV_LOG_RAW("ucPanelPhy2Lane1MuxSel:  %u ", stPanelParam.ucPanelPhy2Lane1MuxSel);
    HV_LOG_RAW("ucPanelPhy2Lane2MuxSel:  %u ", stPanelParam.ucPanelPhy2Lane2MuxSel);
    HV_LOG_RAW("ucPanelPhy2Lane3MuxSel:  %u ", stPanelParam.ucPanelPhy2Lane3MuxSel);
    HV_LOG_RAW("bPanelPhy2Lane0PnSwap:   %u ", stPanelParam.bPanelPhy2Lane0PnSwap);
    HV_LOG_RAW("bPanelPhy2Lane1PnSwap:   %u ", stPanelParam.bPanelPhy2Lane1PnSwap);
    HV_LOG_RAW("bPanelPhy2Lane2PnSwap:   %u ", stPanelParam.bPanelPhy2Lane2PnSwap);
    HV_LOG_RAW("bPanelPhy2Lane3PnSwap:   %u ", stPanelParam.bPanelPhy2Lane3PnSwap);
    return 0;
}
HV_SHELL_EXPORT_CMD(panel_param_debug, Hv_Shell_PanelParamDebug, "show current panel param. panel_param_debug 0: show falsh index 0 param");

/* debug uart switch */
int Hv_Shell_LogCtl(int argc, char* argv[])
{
    /*输入参数数量*/
    if (2 == argc)
    {
        Hv_Vos_LOG_SetLevel(atoi(argv[1]));
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(logctl, Hv_Shell_LogCtl, "0:verbose/debug; 1:info; 2:WARN; 3:ERROR; 4 FATAL/ASSERT; 6:no log");

/* debug uart switch */
int Hv_Shell_EnableUart(int argc, char* argv[])
{
    /*输入参数数量*/
    if (2 == argc)
    {
        if (strcmp("1", argv[1]) == 0)
        {
            Hv_Drv_EnableUart(1);
        }
        else if (strcmp("0", argv[1]) == 0)
        {
            Hv_Drv_EnableUart(0);
        }
        else
        {
            ;
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(uart_enable, Hv_Shell_EnableUart, "1:enable, 0:disable");

#define RX_BUF_SIZE 512
static USHORT16 s_ucRxSize = 0;
static UCHAR8 aucUartRcvBuff[RX_BUF_SIZE]   = {0};
void UART_Callback(UartCallbackType type, void *pArg, UCHAR8 ucSize)
{
    UINT32 iSize = 0;
    switch (type)
    {
        case UART_INT_TX_COMPLETE:
        {
            HV_LOG_RAW("Int Tx Transfer complete!\n");
            break;
        }
        case UART_INT_RX_COMPLETE:
        {
            HV_LOG_RAW("uart rx complete! %x\n", ucSize);
            //s_ucRxSize = 0;
            while (ucSize--)
            {
                aucUartRcvBuff[(s_ucRxSize++)%RX_BUF_SIZE] = *(UCHAR8*)pArg++;
            }

            for (iSize=0; iSize<s_ucRxSize; iSize++)
            {
                //HV_LOGI("recv data:%c\n", aucUartRcvBuff[iSize]);
            }
            //HV_LOG_RAW("uart rx complete! %x\n", pArg);

            break;
        }
        default:
        {
            return;
        }
    }
}

#define TEST_UART_LEN 39
/* uart init. */
VOID TaskTestUartNewMode(INT32 uiBaud)
{
    UartSelf *pstSelf = NULL;
    UartInitParam stInit;
    UINT32 iSize = 0;
    memset(&stInit, 0, sizeof(stInit));

    stInit.enPort       = UART_PORT_1;
    stInit.uiBaudrate   = uiBaud;
    stInit.enParity     = UART_PARITY_NONE;
    stInit.enStopbit    = UART_STOPBIT_1;
    stInit.enWordlen    = UART_WORDLEN_8;
    stInit.bFifoEnable  = HV_TRUE;
    stInit.enRxFiFoTrig = UART_RX_FIFO_CHAR_1;
    stInit.bNewInterface    = HV_TRUE;
    stInit.fCallback        = UART_Callback;
    pstSelf = Hv_Drv_Uart_Init(&stInit);
    Hv_Drv_Uart_EnableReceive(stInit.enPort);
    while (1)
    {
        if (s_ucRxSize)
        {
            for (iSize=0; iSize<s_ucRxSize; iSize++)
            {
                HV_LOGI("recv data:%x \n", aucUartRcvBuff[iSize]);
            }
            s_ucRxSize = 0;
            Hv_Drv_Uart_Send(UART_PORT_1, "OK", 3);
        }
        Hv_Vos_MSleep(50);
    }

    return;
}


static void TaskTestUartMode(UINT32 uiMode)
{
    UartSelf *uart;
    UCHAR8 data[40];
    // for wordlen 7/8 bits, sscom send by char: Hello world! HS_HAL_UART_Transmit test.
    UCHAR8 send[] = {"Hello world! HS_HAL_UART_Transmit test.\n"};


    // set uart param
    UartInitParam initParam;
    memset(&initParam, 0, sizeof(initParam));
    initParam.enPort       = UART_PORT_1;
    initParam.uiBaudrate   = 115200;
    initParam.enParity     = UART_PARITY_NONE;
    initParam.enStopbit    = UART_STOPBIT_1;
    initParam.enWordlen    = UART_WORDLEN_8;
    initParam.fCallback = UART_Callback;
    initParam.pCallbackArg = NULL;

    HV_MEMSET(data, 0, sizeof(data));
    uart = Hv_Drv_Uart_Init(&initParam);

    if (uiMode == 1)
    {
        Hv_Drv_Uart_IntTransmit(uart, send, 39);
        HV_LOGI("int wait recv data\n");

        Hv_Drv_Uart_IntReceive(uart, data, 39);
        Hv_Vos_MSleep(5000);
        HV_LOGI("recv data:%s\n", data);
    }
    else
    {
        Hv_Drv_Uart_Transmit(uart, send, 39, 0);
        HV_LOGI("wait recv data\n");
        Hv_Drv_Uart_Receive(uart, data, 39, 0);
        HV_LOGI("recv data:%s\n", data);
    }

    Hv_Vos_MSleep(1000);
    Hv_Drv_Uart_Cleanup(uart);
    return;
}

INT32 Hv_Shell_Uart_Debug(INT32 argc, CHAR8 *argv[])
{
    if (argc == 1)
    {

        HV_LOG_RAW("uart_test I baudxxx.  8n1.\n");
        HV_LOG_RAW("uart_test p [mode]. 0:polling, 1:int 8n1\n");
        return 0;
    }
    if (0 == strcmp("p", argv[1]))
    {
        TaskTestUartMode(atoi(argv[2]));
    }
    else if (0 == strcmp("I", argv[1]))
    {
        TaskTestUartNewMode(atoi(argv[2]));
    }
    else
    {}

    return 0;
}
SHELL_EXPORT_CMD(uart_test, Hv_Shell_Uart_Debug, "uart_test");
/* sscg test */
int Hv_Shell_Sscg(int argc, char* argv[])
{
    int iType   = 0;
    int iEnable = 0;
    int iFreq   = 30;
    int iStep   = 0;

    /*输入参数数量*/
    if (argc > 2)
    {
        if (strcmp("vbo", argv[1]) == 0)
        {
            iType = 0;
        }
        else if (strcmp("edp", argv[1]) == 0)
        {
            iType = 1;

        }
        else if (strcmp("ddr", argv[1]) == 0)
        {
            iType = 2;
        }
        else
        {
            return -1;
        }

        if (strcmp("enable", argv[2]) == 0)
        {
            iEnable = 1;
        }
        else if (strcmp("disable", argv[2]) == 0)
        {
            iEnable = 0;
        }
        else
        {
            return -1;
        }
        if (argc == 5)
        {
            if (iEnable == 1)
            {
                iFreq = atoi(argv[3]);
                iStep = atoi(argv[4]);
            }
            else
            {
                return -1;
            }
        }
        HV_LOG_RAW("sscg type %d, freq %d, step %d enable %d\r\n", iType, iFreq, iStep, iEnable);
        if (iEnable)
        {
            if ((iFreq < 120) && (iFreq > 20))
            {
                Hv_Drv_Sscg_SetSscgFreq(iType, iFreq);
            }
            Hv_Drv_Sscg_SetSscgStep(iType, iStep);
        }

        Hv_Drv_Sscg_Enalbe(iType, iEnable);
    }

    return 0;
}
HV_SHELL_EXPORT_CMD(sscg, Hv_Shell_Sscg, "sscg vbo/edp/ddr enable freq step;sscg vbo/edp/ddr disable");
/***************************************************************************************************/
/*************************************factory part end *********************************************/
/***************************************************************************************************/


/***************************************************************************************************/
/*************************************audio part start *********************************************/
/***************************************************************************************************/


int Hv_Shell_GetAudioVolume(int argc, char* argv[])
{
    int iVolume;

    iVolume = Hv_Mw_Audio_GetVolume();
    HV_LOG_RAW("Audio Volume = %d\r\n", iVolume);

    return 0;
}
HV_SHELL_EXPORT_CMD(get_audio_volume, Hv_Shell_GetAudioVolume, "Volume(type int):0-100");

int Hv_Shell_SetAudioVolume(int argc, char* argv[])
{
    int iVolume;
    if (2 == argc)
    {
        iVolume = atoi(argv[1]);
        HV_LOG_RAW("Audio Volume = %d\r\n", iVolume);
        Hv_Mw_Audio_SetVolume(iVolume);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_audio_volume, Hv_Shell_SetAudioVolume, "Volume(type int):0-100");

int Hv_Shell_SetAudioMute(int argc, char* argv[])
{
    Hv_Mw_Audio_UIMute();
    HV_LOG_RAW("Audio Mute!\r\n");

    return 0;
}
HV_SHELL_EXPORT_CMD(set_audio_mute, Hv_Shell_SetAudioMute, "Set Audio Mute");

int Hv_Shell_SetAudioUnMute(int argc, char* argv[])
{
    Hv_Mw_Audio_UIUnMute();
    HV_LOG_RAW("Audio unMute!\r\n");

    return 0;
}
HV_SHELL_EXPORT_CMD(set_audio_unmute, Hv_Shell_SetAudioUnMute, "Set Audio UnMute");

int Hv_Shell_GetAudioEQMode(int argc, char* argv[])
{
    int iValue;

    iValue = Hv_Mw_Audio_GetEQMode();
    HV_LOG_RAW("Audio EQMode = %d\r\n", iValue);

    return 0;
}
HV_SHELL_EXPORT_CMD(get_audio_eq_mode, Hv_Shell_GetAudioEQMode, "0-ROCK, 1-POP, 2-LIVE, 3-DANCE, 4-CLUB, 5-POWER");

int Hv_Shell_SetAudioEQMode(int argc, char* argv[])
{
    int iValue;

    if (2 == argc)
    {
        iValue = atoi(argv[1]);
        HV_LOG_RAW("Audio EQMode = %d\r\n", iValue);
        Hv_Mw_Audio_SetEQMode(iValue);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_audio_eq_mode, Hv_Shell_SetAudioEQMode, "0-ROCK, 1-POP, 2-LIVE, 3-DANCE, 4-CLUB, 5-POWER");

int Hv_Shell_GetAudioDelayTime(int argc, char* argv[])
{
    int iDelayTime;

    iDelayTime = Hv_Mw_Audio_GetDelayTime();
    HV_LOG_RAW("Audio Delay Time = %dms\r\n", iDelayTime);

    return 0;
}
HV_SHELL_EXPORT_CMD(get_audio_delay_time, Hv_Shell_GetAudioDelayTime, "DelayTime(type int):0-500,ms,step 50ms");

int Hv_Shell_SetAudioDelayTime(int argc, char* argv[])
{
    int iDelayTime;
    if (2 == argc)
    {
        iDelayTime = atoi(argv[1]);
        HV_LOG_RAW("Audio Delay Time = %dms\r\n", iDelayTime);
        Hv_Mw_Audio_SetDelayTime(iDelayTime);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_audio_delay_time, Hv_Shell_SetAudioDelayTime, "DelayTime(type int):0-500,ms,step 50ms");

int Hv_Shell_SelectSoundResource(int argc, char* argv[])
{
    int iValue = 0;
    int iChannelType = 0;

    if (2 == argc)
    {
        iValue = atoi(argv[1]);
        HV_LOG_RAW("SoundResource ChannelIndex = %d\r\n", iValue);
    }

    if (3 == argc)
    {
        iChannelType = atoi(argv[1]);
        HV_LOG_RAW("SoundResource ChannelType = %d\r\n", iChannelType);
    }

    Hv_Mw_Audio_SelectSound(iValue, iChannelType);
    return 0;
}
HV_SHELL_EXPORT_CMD(select_sound_resource, Hv_Shell_SelectSoundResource, "ChannelIndex: 0-HDMI_0,  1-HDMI_1,  2-DP_0,  3-DP_1 \n ChannelType: 0-main,  1-sub");

/*************************************************
    Debug Interface
*************************************************/

int Hv_Shell_SetAudioReset(int argc, char* argv[])
{
    if (2 == argc)
    {
        if (0 == strcmp("0", argv[1]))  //select 0
        {
            HV_W32_FIELD(SYS_SH06_TOP_04,       reg_audio_rst_n,            0);
            HV_W32_FIELD(SYS_SH06_TOP_04,       reg_audio_axi_rst_n,        0);

            HV_W32_FIELD(SYS_SH06_TOP_04,       reg_audio_rst_n,            1);
            HV_W32_FIELD(SYS_SH06_TOP_04,       reg_audio_axi_rst_n,        1);

            HV_LOG_RAW("close Reset Audio IP success.\r\n");
        }
        else                            //select 1
        {
            HV_W32_FIELD(SYS_SH06_TOP_04,               reg_ip_rst_n,       0);
            HV_W32_FIELD(SYS_REG_SH5_TOP0_MIPS0_CTRL1,  mips0_reg_rstn,     0);

            HV_W32_FIELD(SYS_SH06_TOP_04,               reg_ip_rst_n,       1);
            HV_W32_FIELD(SYS_REG_SH5_TOP0_MIPS0_CTRL1,  mips0_reg_rstn,     1);

            HV_LOG_RAW("close Reset MIPS success.\r\n");
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_audio_reset, Hv_Shell_SetAudioReset, "0-reset audio,    1-reset MIPS");

int Hv_Shell_SetAudioPattern(int argc, char* argv[])
{
    int iRegValue;
    HV_R32_DECL_VAR();
    iRegValue = HV_R32_FIELD(RX_AUDIO_TOP0_00,  reg_audio_rx_out_sel);

    if (2 == argc)
    {
        if (0 == strcmp("0", argv[1]))      //select 0
        {
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_rx_out_sel,       3);
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_pattern_ctl,      3);

            HV_W32_FIELD(RX_AUDIO_TOP1_E8,      reg_audio_tx_i2s_pcm_sel,   0);
            HV_W32_FIELD(RX_AUDIO_TOP1_DC,      reg_audio_i2s_tx_en,        1);

            HV_W32_FIELD(RX_AUDIO_TOP1_EC,      reg_audio_tx_spdif_pcm_sel, 0);
            HV_W32_FIELD(RX_AUDIO_TOP1_04,      reg_audio_spdif_tx_en,      1);

            HV_R32_DECL_VAR();
            HV_LOG_RAW("RX_AUDIO_TOP0_F4        regr_audio_i2s_rx_fs_0  0x%x        .\r\n",
                HV_R32_FIELD(RX_AUDIO_TOP0_F4,  regr_audio_i2s_rx_fs_0));
        }
        else if(0 == strcmp("1", argv[1]))  //select 1
        {
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_rx_out_sel,       3);
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_pattern_ctl,      3);
        }
        else if(0 == strcmp("2", argv[1]))  //select 2
        {
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_rx_out_sel,       iRegValue);
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_pattern_ctl,      0);
        }
        else if(0 == strcmp("3", argv[1]))  //select 3
        {
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_pattern_ctl,      0);
        }
        else if(0 == strcmp("4", argv[1]))  //select 4
        {
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_pattern_ctl,      3);
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_audio_pattern, Hv_Shell_SetAudioPattern, "0-Pattern audio path, 1-Play pattern only,    2-Resume audio, 3-Mute Pattern, 4-No.3 Pattern");

int Hv_Shell_SetAudioRXout(int argc, char* argv[])
{
    int iRegValue;
    HV_R32_DECL_VAR();
    iRegValue = HV_R32_FIELD(RX_AUDIO_TOP0_00,  reg_audio_rx_out_sel);

    if (2 == argc)
    {
        if (0 == strcmp("0", argv[1]))      //select 0
        {
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_rx_out_sel,       0);
        }
        else if(0 == strcmp("1", argv[1]))  //select 1
        {
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_rx_out_sel,       1);
        }
        else if(0 == strcmp("2", argv[1]))  //select 2
        {
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_rx_out_sel,       2);
        }
        else if(0 == strcmp("3", argv[1]))  //select 3
        {
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_rx_out_sel,       3);
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_pattern_ctl,      3);
        }
        else if(0 == strcmp("4", argv[1]))  //select 4
        {
            HV_W32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_rx_out_sel,       4);
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_audio_rx_out, Hv_Shell_SetAudioRXout, "0-I2S, 1-spdif, 2-DP, 3-Pattern, 4-HDMI");

int Hv_Shell_SetAudioEQ(int argc, char* argv[])
{
    int iValue;
    if (2 == argc)
    {
        iValue = atoi(argv[1]);
        switch (iValue)
        {
            case 0:
            {
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf0_en_ch01,          _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf1_en_ch01,          _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf2_en_ch01,          _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf0_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf1_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf2_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf3_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf4_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf5_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf6_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf7_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf8_en_ch01,           _AUDIO_FLAG_DISABLE);
                break;
            }
            case 1:
            {
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf0_en_ch01,          _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf1_en_ch01,          _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf2_en_ch01,          _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf0_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf1_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf2_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf3_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf4_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf5_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf6_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf7_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf8_en_ch01,           _AUDIO_FLAG_ENABLE);
                break;
            }
            case 2:
            {
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf0_en_ch01,          _AUDIO_FLAG_DISABLE);
                break;
            }
            case 3:
            {
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf0_en_ch01,          _AUDIO_FLAG_ENABLE);
                break;
            }
            case 4:
            {
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf1_en_ch01,          _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf2_en_ch01,          _AUDIO_FLAG_DISABLE);
                break;
            }
            case 5:
            {
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf1_en_ch01,          _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_hlpf2_en_ch01,          _AUDIO_FLAG_ENABLE);
                break;
            }
            case 6:
            {
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf0_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf1_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf2_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf3_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf4_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf5_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf6_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf7_en_ch01,           _AUDIO_FLAG_DISABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf8_en_ch01,           _AUDIO_FLAG_DISABLE);
                break;
            }
            case 7:
            {
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf0_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf1_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf2_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf3_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf4_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf5_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf6_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf7_en_ch01,           _AUDIO_FLAG_ENABLE);
                HV_W32_FIELD(RX_AUDIO_TOP3_08, reg_audio_eq_bpf8_en_ch01,           _AUDIO_FLAG_ENABLE);
                break;
            }
            default:
            {
                HV_LOG_RAW("An error setting!\n");
                return HV_FAILURE;
            }
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_audio_eq, Hv_Shell_SetAudioEQ, "0-ALL OFF,  1-ALL ON,   2-LPF OFF,  3-LPF ON,   4-HPF OFF,  5-HPF ON,   6-BPF OFF,  7-BPF ON");

int Hv_Shell_SetAudioGPIOinput(int argc, char* argv[])
{
    if (2 == argc)
    {
        if (0 == strcmp("0", argv[1]))  //select 0
        {
            //I2S_SDIN
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_2C,    reg_gpio24_io_ctrl,                 64);
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_8,     reg_i2s_sd_in_pad_in_sel,           0);
            //I2S_WS_IN
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_2C,    reg_gpio25_io_ctrl,                 64);
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_8,     reg_i2s_ws_in_pad_in_sel,           0);
            //I2S_SCK_IN
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_30,    reg_gpio26_io_ctrl,                 64);
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_8,     reg_i2s_sck_in_pad_in_sel,          0);

            //SPDIF_IN
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_30,    reg_gpio27_io_ctrl,                 64);
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_8,     reg_spdif_in_pad_in_sel,            1);
            HV_W32_FIELD(RX_SH08_TOP_RX_0X40,       reg_spdif_in_pad_use_sel ,          1);

            HV_LOG_RAW("set GPIO input mode.\r\n");
        }
        else                            //select 1
        {
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_0,     reg_gpio23_func_sel,                6);
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_C,     reg_gpio23_pin_sel,                 0);
            HV_W32_FIELD(RX_SH08_TOP_RX_CTRL_2C,    reg_gpio23_io_ctrl,                 111);

            HV_LOG_RAW("set GPIO23.\r\n");
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_audio_input_gpio, Hv_Shell_SetAudioGPIOinput, "0-input,   1-set GPIO23");

/*************************************************
    Status Inquiry
*************************************************/

int Hv_Shell_ShowAudioConfig(int argc, char* argv[])
{
    HV_R32_DECL_VAR();
    HV_LOG_RAW("Page                        Register                    Value       Describe\r\n\r\n");
    HV_LOG_RAW("reset:\r\n");
    HV_LOG_RAW("SYS_SH06_TOP_04             reg_audio_rst_n             0x%x        audio IP reset.\r\n",
        HV_R32_FIELD(SYS_SH06_TOP_04,       reg_audio_rst_n));
    HV_LOG_RAW("SYS_SH06_TOP_04             reg_audio_axi_rst_n         0x%x        audio DDR reset.\r\n\r\n",
        HV_R32_FIELD(SYS_SH06_TOP_04,       reg_audio_axi_rst_n));

    HV_LOG_RAW("path:\r\n");
    HV_LOG_RAW("RX_AUDIO_TOP0_08            reg_audio_i2s_rx_en         0x%x        RX in(i2s).\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP0_08,      reg_audio_i2s_rx_en));
    HV_LOG_RAW("RX_AUDIO_TOP0_08            reg_audio_i2s_rx_src_sel_0  0x%x        RX in(i2s).\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP0_08,      reg_audio_i2s_rx_src_sel_0));
    HV_LOG_RAW("RX_AUDIO_TOP0_04            reg_audio_spdif_rx_en           0x%x    RX in(spdif).\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP0_04,      reg_audio_spdif_rx_en));
    HV_LOG_RAW("RX_AUDIO_TOP0_04            reg_audio_spdif_rx_src_sel_0    0x%x    RX in(spdif).\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP0_04,      reg_audio_spdif_rx_src_sel_0));
    HV_LOG_RAW("RX_AUDIO_TOP0_00            reg_audio_rx_out_sel        0x%x        RX out.\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP0_00,      reg_audio_rx_out_sel));
    HV_LOG_RAW("RX_AUDIO_TOP2_AUDIO_DM_0    reg_audio_dm_pcm_sel        0x%x        DM in.\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP2_AUDIO_DM_0,      reg_audio_dm_pcm_sel));
    HV_LOG_RAW("RX_AUDIO_TOP3_00            reg_audio_hw_pcm_sel        0x%x        HW in.\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP3_00,      reg_audio_hw_pcm_sel));
    HV_LOG_RAW("RX_AUDIO_TOP1_DC            reg_audio_i2s_tx_en         0x%x        TX in(i2s).\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP1_DC,      reg_audio_i2s_tx_en));
    HV_LOG_RAW("RX_AUDIO_TOP1_E8            reg_audio_tx_i2s_pcm_sel    0x%x        TX in(i2s).\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP1_E8,      reg_audio_tx_i2s_pcm_sel));
    HV_LOG_RAW("RX_AUDIO_TOP1_04            reg_audio_spdif_tx_en       0x%x        TX in(spdif).\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP1_04,      reg_audio_spdif_tx_en));
    HV_LOG_RAW("RX_AUDIO_TOP1_EC            reg_audio_tx_spdif_pcm_sel  0x%x        TX in(spdif).\r\n\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP1_EC,      reg_audio_tx_spdif_pcm_sel));

    HV_LOG_RAW("HDMI-fs:\r\n");
    HV_LOG_RAW("RX_AUDIO_TOP0_F4            regr_audio_i2s_rx_fs_0      0x%x        HDMI-fs.\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP0_F4,      regr_audio_i2s_rx_fs_0));

    HV_LOG_RAW("clock:\r\n");
    HV_LOG_RAW("RX_RX_PHY_2C                reg_lane_clk_src_aud_sel    0x%x        lane clock.\r\n",
        HV_R32_FIELD(RX_RX_PHY_2C,          reg_lane_clk_src_aud_sel));
    HV_LOG_RAW("RX_AUDIO_TOP2_AUDIO_PLL_2   reg_audio_pll_0_ckref_sel   0x%x        pll0 reference clock.\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP2_AUDIO_PLL_2,     reg_audio_pll_0_ckref_sel));
    HV_LOG_RAW("RX_AUDIO_TOP2_90            reg_audio_pll_0_fbdiv_sel   0x%x        .\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP2_90,      reg_audio_pll_0_fbdiv_sel));
    HV_LOG_RAW("RX_AUDIO_TOP2_90            reg_audio_pll_0_fbdiv_ratio 0x%x        .\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP2_90,      reg_audio_pll_0_fbdiv_ratio));
    HV_LOG_RAW("RX_AUDIO_TOP2_              regr_audio_pll_lockdet_pll_lock 0x%x    pll lock flag.\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP2_AUDIO_PLL_DET_2, regr_audio_pll_lockdet_pll_lock));
    HV_LOG_RAW("RX_AUDIO_TOP2_F4            regr_audpll_pg0_det_mon_cnt 0x%x        .\r\n",
        HV_R32_FIELD(RX_AUDIO_TOP2_F4,      regr_audpll_pg0_det_mon_cnt));

    return 0;
}
HV_SHELL_EXPORT_CMD(show_audio_config, Hv_Shell_ShowAudioConfig, "show audio's config");

int Hv_Shell_GetAudioVolumeStatus(int argc, char* argv[])
{
    if (g_bHeadsetInsertion)
    {
        HV_LOG_RAW("Headset port is plugged \r\n");
    }
    else
    {
        HV_LOG_RAW("Headset port is empty \r\n");
    }

    if (HV_PROJECT_CONFIG_VOLUME_CONSISTENT)
    {
        HV_LOG_RAW("Headset and speaker use the same volume value \r\n");
    }
    else
    {
        HV_LOG_RAW("Headset and speaker use different volume values \r\n");
    }

    return 0;
}
HV_SHELL_EXPORT_CMD(get_audio_volume_status, Hv_Shell_GetAudioVolumeStatus, "Show audio volume status");

int Hv_Shell_ReadAudioHDMIfs(int argc, char* argv[])
{
    int iRegValue;

    HV_R32_DECL_VAR();
    if (1 == argc)
    {
        iRegValue = HV_R32_FIELD(RX_AUDIO_TOP0_F4,      regr_audio_i2s_rx_fs_0);
        switch (iRegValue)
        {
            case 0:
            {
                HV_LOG_RAW("HDMI fs non detect!\n");
                break;
            }
            case 1:
            {
                HV_LOG_RAW("HDMI fs is 192k!\n");
                break;
            }
            case 2:
            {
                HV_LOG_RAW("HDMI fs is 176.4k!\n");
                break;
            }
            case 3:
            {
                HV_LOG_RAW("HDMI fs is 96k!\n");
                break;
            }
            case 4:
            {
                HV_LOG_RAW("HDMI fs is 88.2k!\n");
                break;
            }
            case 5:
            {
                HV_LOG_RAW("HDMI fs is 48k!\n");
                break;
            }
            case 6:
            {
                HV_LOG_RAW("HDMI fs is 44.1k!\n");
                break;
            }
            case 7:
            {
                HV_LOG_RAW("HDMI fs is 32K!\n");
                break;
            }
            case 8:
            {
                HV_LOG_RAW("HDMI fs is 16K!\n");
                break;
            }
            case 9:
            {
                HV_LOG_RAW("HDMI fs is 8K!\n");
                break;
            }
            default:
            {
                HV_LOG_RAW("An error fs!\n");
                return HV_FAILURE;
            }
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(read_audio_hdmi_fs, Hv_Shell_ReadAudioHDMIfs, "read current HDMI-port's fs from regr_audio_i2s_rx_fs_0");

int Hv_Shell_ReadAudioDPfs(int argc, char* argv[])
{
    int iLaneClk;
    int iMaud;
    int iNaud;
    float fDPfs;

    HV_R32_DECL_VAR();
    if (1 == argc)
    {
        iLaneClk = HV_R32_FIELD(RX_EDP_RX_MAC_RO_REG_00_54,             regr_00_dprx_mac_clkdet_freq_cnt);
        HV_LOG_RAW("iLaneClk is %d!\n", iLaneClk);
        iMaud = HV_R32_FIELD(RX_EDP_RX_MAC_BP_REG_00_80,                regr_00_dprx_sdp_maud);
        HV_LOG_RAW("iMaud is %d!\n", iMaud);
        iNaud = HV_R32_FIELD(RX_EDP_RX_MAC_BP_REG_00_84,                regr_00_dprx_sdp_naud);
        HV_LOG_RAW("iNaud is %d!\n", iNaud);
        if (!iNaud)
        {
            return 1;
        }
        fDPfs = (float)(iMaud /iNaud);
        HV_LOG_RAW("(iMaud /iNaud) is %3.2f!\n", fDPfs);
        fDPfs *= iLaneClk;
        HV_LOG_RAW("iLaneClk*(iMaud /iNaud) is %3.2f!\n", fDPfs);
        fDPfs *= 20;
        HV_LOG_RAW("DP0 fs is %3.2fK!\n", fDPfs);

        iLaneClk = HV_R32_FIELD(RX_EDP_RX_MAC_RO_REG_01_54,             regr_01_dprx_mac_clkdet_freq_cnt);
        HV_LOG_RAW("iLaneClk is %d!\n", iLaneClk);
        iMaud = HV_R32_FIELD(RX_EDP_RX_MAC_BP_REG_01_80,                regr_01_dprx_sdp_maud);
        HV_LOG_RAW("iMaud is %d!\n", iMaud);
        iNaud = HV_R32_FIELD(RX_EDP_RX_MAC_BP_REG_01_84,                regr_01_dprx_sdp_naud);
        HV_LOG_RAW("iNaud is %d!\n", iNaud);
        if (!iNaud)
        {
            return 1;
        }
        fDPfs = (float)(iMaud /iNaud);
        HV_LOG_RAW("(iMaud /iNaud) is %3.2f!\n", fDPfs);
        fDPfs *= iLaneClk;
        HV_LOG_RAW("iLaneClk*(iMaud /iNaud) is %3.2f!\n", fDPfs);
        fDPfs *= 20;
        HV_LOG_RAW("DP1 fs is %3.2fK!\n", fDPfs);
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(read_audio_dp_fs, Hv_Shell_ReadAudioDPfs, "calculate all DP-port's fs from registers");
/***************************************************************************************************/
/*************************************audio part end *********************************************/
/***************************************************************************************************/




/***************************************************************************************************/
/*************************************dispctrl part start *********************************************/
/***************************************************************************************************/
#ifdef CONFIG_USER_DISPCTRL_OD_ON
int Hv_Shell_SetOdLevel(int argc, char* argv[])
{
    if (2 == argc)
    {
        if (0 == strcmp("0", argv[1]))  //low
        {
            Hv_Mw_PQ_SetODLevel(0);
        }
        else if (0 == strcmp("1", argv[1])) //mid
        {
            Hv_Mw_PQ_SetODLevel(1);
        }
        else if (0 == strcmp("2", argv[1])) //high
        {
            Hv_Mw_PQ_SetODLevel(2);
        }
        else if (0 == strcmp("3", argv[1])) //off
        {
            Hv_Mw_PQ_SetODLevel(3);
        }
        else
        {
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(set_od_level, Hv_Shell_SetOdLevel, "0-low, 1-mid, 2-high, 3-off");
#endif

int Hv_Shell_SetDemuraLevel(int argc, char* argv[])
{
    if (2 == argc)
    {
        if (0 == strcmp("0", argv[1]))  
        {
            Hv_Mw_PQ_SetDemuraLevel(0);
        }
        else if (0 == strcmp("1", argv[1]))
        {
            Hv_Mw_PQ_SetDemuraLevel(1);
        }
        else if (0 == strcmp("2", argv[1]))
        {
            HV_LOG_RAW("demura crc %d\n", Hv_Mw_PQ_GetDemuraCrcFlag());
        }
        else 
        {
        }
    }
    return 0;
}
HV_SHELL_EXPORT_CMD(demura, Hv_Shell_SetDemuraLevel, "0-off, 1-on, 2-get crc flag");

/***************************************************************************************************/
/*************************************dispctrl part end *********************************************/
/***************************************************************************************************/




/***************************************************************************************************/
/*************************************gpio part start *********************************************/
/***************************************************************************************************/
static int Hv_Shell_GpioDirCtrl(int argc, char* argv[])
{
    if (3 == argc)
    {
        UCHAR8 ucPinIdx = (UCHAR8)atoi(argv[1]);
        GpioDir enDir = (GpioDir)atoi(argv[2]);
        Hv_Drv_Gpio_SetDirection(ucPinIdx, enDir);
        HV_LOGI("Set Pin (%d) Dir(%s)\n", ucPinIdx, enDir?"Output":"Input");
    }
    else
    {
        UCHAR8 ucPinIdx = (UCHAR8)atoi(argv[1]);
        GpioDir enDir = Hv_Drv_Gpio_GetDirection(ucPinIdx);
        HV_LOGI("Get Pin (%d) Dir(%s)\n", ucPinIdx, enDir?"Output":"Input");
    }
    return 0;
}

SHELL_EXPORT_CMD(gpio_dir, Hv_Shell_GpioDirCtrl, "gpio_dir <pin 0-255> <output-1/input-0>");

static int Hv_Shell_GpioLevelCtrl(int argc, char* argv[])
{
    if (3 == argc)
    {
        UCHAR8 ucPinIdx = (UCHAR8)atoi(argv[1]);
        GpioLevel enLevel = (GpioLevel)atoi(argv[2]);
        Hv_Drv_Gpio_SetPinLevel(ucPinIdx, enLevel);
        HV_LOGI("Set Pin (%d) Level(%s)\n", ucPinIdx, enLevel?"High":"Low");
    }
    else
    {
        UCHAR8 ucPinIdx = (UCHAR8)atoi(argv[1]);
        GpioLevel enLevel = Hv_Drv_Gpio_GetPinLevel(ucPinIdx);
        HV_LOGI("Get Pin (%d) Level(%s)\n", ucPinIdx, enLevel?"High":"Low");
    }
    return 0;
}

SHELL_EXPORT_CMD(gpio_level, Hv_Shell_GpioLevelCtrl, "gpoi_level <pin 0-255> <High-1/Low-0>");
/***************************************************************************************************/
/*************************************gpio part end *********************************************/
/***************************************************************************************************/

/***************************************************************************************************/
/***********************************9bit-uart led test *********************************************/
/***************************************************************************************************/
static int Hv_Shell_LedTest(int argc, char* argv[])
{
    if (1 == argc)
    {
        HV_LOGI("mode 1:long red  2:long blue  3:third color  4:running led 5:fantasy color r:read version  0:close all led\n");
        return 0;
    }

    UartInitParam stInit;
    UartSelf *pstSelf = NULL;

    memset(&stInit, 0, sizeof(stInit));
    stInit.enPort = UART_PORT_1;
    stInit.uiBaudrate = 115200;
    stInit.enParity = UART_PARITY_NONE;
    stInit.enStopbit = UART_STOPBIT_1;
    stInit.enWordlen = UART_WORDLEN_8;
    stInit.b9BitMode = 0;
    stInit.bFifoEnable = 1;
    pstSelf = Hv_Drv_Uart_Init(&stInit);
    //Hv_Drv_Uart_PutAddr(pstSelf, 0x7c);
    Hv_Drv_Gpio_SetDirection(215,1);
    Hv_Drv_Gpio_SetPinLevel(215,1);
    if (0 == strcmp("r", argv[1]))
    {
        UCHAR8 aucReadVersion[20]= {0};
        //UCHAR8 aucTestPattern[5] = {0xaa,0x55,0xf8,0xf9,0xfa};
        UCHAR8 aucTestPattern[5] = {0xf8,0xf9};
        Hv_Drv_Uart_Transmit(pstSelf, aucTestPattern, 2, 0);
        Hv_Drv_Uart_Receive(pstSelf, aucReadVersion, 12, 1000);
        HV_LOGI("read version: %s\n", aucReadVersion);
    }
    else if (0 == strcmp("0", argv[1]))
    {
        UCHAR8 aucTestPattern[4] = {0xaa,0x55,0x0,0xfa};

        HV_LOGI("close: led\n");
        Hv_Drv_Uart_Transmit(pstSelf, aucTestPattern, 4, 0);
    }
    else if (0 == strcmp("a", argv[1]))
    {
        HV_LOGI("send addr\n");
        Hv_Drv_Uart_PutAddr(pstSelf, 0x7c);
    }
    else if (0 == strcmp("s", argv[1]))
    {
        HV_LOGI("send data\n");
        Hv_Drv_Uart_PutChar(pstSelf, 'm');
        Hv_Drv_Uart_PutChar(pstSelf, 'a');
        Hv_Drv_Uart_PutChar(pstSelf, 'g');
        Hv_Drv_Uart_PutChar(pstSelf, 'i');
        Hv_Drv_Uart_PutChar(pstSelf, 'c');
    }
    else
    {
        UCHAR8 aucTestPattern[4] = {0xaa,0x55,0x0,0xfa};

        aucTestPattern[2] = 0xf0 + atoi(argv[1]);
        HV_LOGI("led type: %x\n", aucTestPattern[2]);
        Hv_Drv_Uart_Transmit(pstSelf, aucTestPattern, 4, 0);
    }
    HV_LOGI("for cleanup.\n");
    Hv_Drv_Uart_Cleanup(pstSelf);
    //Hv_Drv_Gpio_SetPinLevel(215,0);
    return 0;
}
SHELL_EXPORT_CMD(9bituartledtest, Hv_Shell_LedTest, "9bituartledtest mode");
/***************************************************************************************************/
/************************************9bit-uart led test*********************************************/
/***************************************************************************************************/

/***************************************************************************************************/
/***********************************i2c test *********************************************/
/***************************************************************************************************/
#define SLAVE_ADDRESS  (0xa0 >> 1)
#define TEST_I2C_PORT   0
#define TEST_I2C_SPEED  I2C_SPEED_50K
#define TEST_I2C_CMDADDSIZE 1


UCHAR8 HV_WtRdI2cDataCheck(UCHAR8* pTxData, UCHAR8* pRxData, USHORT16 size)
{
    USHORT16  ii = 0;
    UCHAR8  ret = 0;
    for( ii = 0; ii < size ; ii++) {
        if(pTxData[ii] != pRxData[ii]) {
            ret = 2;
            return ret;
        }
    }
    return HV_SUCCESS;
}


UCHAR8 pTxData[34] = { 0x00, 0x02, 0x19, 0x30, 0x50, 0x05, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x14, 0x12,
                       0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x25,
                       0x29, 0x37
                     };
UCHAR8 pRxData[40] = {0};


void TaskTestI2CParam(UINT32 uiPort, UINT32 uiSpeed, UINT32 uiAddrMode)
{
    UINT32 ret = 0;
    UINT32 i = 0;
    UINT32 size = 8;
    UCHAR8 pAddrCmd[2] = {0x00, 0x00};

    HvCalI2c *self;
    I2cInitParam initParam;
    I2cFuncParam funcParameter;

    initParam.enPort = uiPort;
    initParam.enMode = I2C_MODE_MASTER;
    initParam.enSpeed = uiSpeed;
    initParam.enAddressingMode = uiAddrMode;
    HV_LOG_RAW("TaskTestI2CParam\n");
    self = Hv_Drv_I2C_Init(&initParam);
    pTxData[0] = 0x26;

    //while (1)
    {
        size = 8;
        funcParameter.usDevAddress = (0xA0>>1);
        funcParameter.pucCmdAddr = pAddrCmd;
        funcParameter.pucData = pTxData;
        funcParameter.usCmdAddrSize = TEST_I2C_CMDADDSIZE;
        funcParameter.usDataSize = size;
        HV_LOG_RAW("Hv_Drv_I2C_MasterPollingTransmit start\n");
        ret = Hv_Drv_I2C_MasterPollingTransmit(self, &funcParameter, 0);
        HV_LOG_RAW("end!ret = %d\n",ret);
        size = size * 2;
        funcParameter.usDevAddress = (0xA0>>1);
        funcParameter.pucCmdAddr = pAddrCmd;
        funcParameter.pucData = pRxData;
        funcParameter.usCmdAddrSize = TEST_I2C_CMDADDSIZE;
        funcParameter.usDataSize = size;

        Hv_Vos_MSleep(20);
        ret = Hv_Cal_I2C_MasterPollingReceive(self, &funcParameter, 500);
        for(i = 0; i < size; i++) {
            HV_LOG_RAW("I2C-Polling:pRxData[%d]= 0x%02x\n", i, pRxData[i]);
        }
        HV_LOG_RAW("Hv_Cal_I2C_MasterPollingReceive end!ret = %d\n",ret);
    }
    Hv_Vos_MSleep(5000);
    Hv_Drv_I2C_Cleanup(self);
    self = NULL;
    return;
}

#define RX_BUF_SIZE 512
UCHAR8 aucI2CBuf[RX_BUF_SIZE] = {0};
volatile UCHAR8 ucI2cStopped = 0;
volatile UCHAR8 ucI2cRestart = 0;
volatile USHORT16 usI2cReceiveIndex = 0;
volatile USHORT16 ucI2cReadIndex = 0;
volatile UCHAR8 ucI2cRxSize = 0;
static Status fTestI2CBack(I2cTransType enTransType, VOID *pvArg)
{
    HvCalI2c *pstSelf = (HvCalI2c*)pvArg;
    if (I2C_SLAVE_RECEIVE == enTransType)
    {
        ucI2cRxSize = pstSelf->usRxferCount;
        HV_LOG_RAW("buf rx size:%d\n", ucI2cRxSize);
        Hv_Vos_Memcpy(aucI2CBuf, pstSelf->pucRxBuff, pstSelf->usRxferCount);
        #if 1
            for (INT32 iLoop = 0; iLoop < ucI2cRxSize; iLoop++)
            {
                HV_LOG_RAW("%x ", aucI2CBuf[iLoop]);
            }
        #endif
        //Hv_Cal_I2C_SlaveIntReceiveEnable(0);
    }
    return HV_SUCCESS;

}

static Status fTestI2CBackR(I2cTransType enTransType, VOID *pvArg)
{
    HvCalI2c *pstSelf = (HvCalI2c*)pvArg;
    UCHAR8 ucI2cRxSize = 0;
    if (I2C_SLAVE_RECEIVE == enTransType)
    {
        ucI2cRxSize = pstSelf->usRxferCount;
        //HV_LOG_RAW("buf rx:%d\n", ucI2cRxSize);
        while (ucI2cRxSize--)
        {
            aucI2CBuf[(usI2cReceiveIndex++)%RX_BUF_SIZE] = *(pstSelf->pucRxBuff++);
        }

        if (usI2cReceiveIndex >= RX_BUF_SIZE)
        {
            usI2cReceiveIndex -= RX_BUF_SIZE;
        }
        //Hv_Cal_I2C_SlaveIntReceiveEnable(0);
    }
    else if (I2C_SLAVE_STOP == enTransType)
    {
        HV_LOG_RAW("i2c stop\n" );
        ucI2cStopped = 1;
    }
    else if (I2C_SLAVE_RESTART == enTransType)
    {
        //HV_LOG_RAW("i2c restart\n");
        ucI2cRestart = 1;
    }
    else
    {

    }
    return HV_SUCCESS;
}

void TaskTestI2CSlaveMode(void)
{
    I2cFuncParam   enI2cParam;
    I2cInitParam  stInitParam;
    HvCalI2c *s_pstSalveI2C = NULL;
    UCHAR8 ucTestCount = 15;
    INT32 iLoop = 0;
    USHORT16 usSize = 0;

    //Hv_Cal_I2C_InitPin(I2C_MODE_SLAVE, CONFIG_AT_I2C_PORT);
    stInitParam.enPort  = 0;
    stInitParam.enMode  = I2C_MODE_SLAVE;
    stInitParam.enSpeed = I2C_SPEED_50K;
    stInitParam.enAddressingMode = I2C_ADDR_7BIT;
    stInitParam.OwnAddress = 0x55;
    stInitParam.bNewInterface = HV_TRUE;
    stInitParam.fI2cCpltCallback = fTestI2CBackR;
    s_pstSalveI2C = Hv_Cal_I2C_Init(&stInitParam);
    Hv_Cal_I2C_SlaveIntReceiveEnable(0);

    while (1)
    {
        if (ucI2cStopped)
        {
            ucI2cStopped = 0;

            if (ucI2cReadIndex >= RX_BUF_SIZE)
            {
                ucI2cReadIndex -= RX_BUF_SIZE;
            }
            if (usI2cReceiveIndex > ucI2cReadIndex)
            {
                usSize = usI2cReceiveIndex - ucI2cReadIndex;
            }
            else if (usI2cReceiveIndex < ucI2cReadIndex)
            {
                usSize = RX_BUF_SIZE - ucI2cReadIndex + usI2cReceiveIndex;
            }
            else
            {
                usSize = 0;
            }
            if (usSize)
            {
                HV_LOG_RAW("buf remain: %d ", usSize);
                for (iLoop = 0; iLoop < usSize; iLoop++)
                {
                    HV_LOG_RAW("%x ", aucI2CBuf[(ucI2cReadIndex+iLoop)%RX_BUF_SIZE]);
                    aucI2CBuf[(ucI2cReadIndex+iLoop)%RX_BUF_SIZE] += 2;
                }
                HV_LOG_RAW("\n");

                //while (ucI2cRestart == 0);
                //ucI2cRestart = 0;
                HV_LOG_RAW("send \n");
                //Hv_Cal_I2C_SlaveTransmit(0, aucI2CBuf, usSize-1);
                Hv_Cal_I2C_SlaveIntTransmit(s_pstSalveI2C, &aucI2CBuf[(ucI2cReadIndex+1)%RX_BUF_SIZE], usSize-1);
                ucI2cReadIndex += usSize;
                ucI2cReadIndex += 1;
                ucTestCount--;
                if (0 == ucTestCount)
                {
                    break;
                }
                Hv_Cal_I2C_SlaveIntReceiveEnable(0);
                HV_LOG_RAW("exit \n");
            }
        }
        else
        {
            //HV_LOG_RAW("no data:\n");
            Hv_Vos_MSleep(20);
        }
    }
    Hv_Vos_MSleep(5000);
    Hv_Cal_I2C_Cleanup(s_pstSalveI2C);
    s_pstSalveI2C = NULL;
    return;
}

void TaskTestI2CSlaveModeRceivce(void)
{
    I2cFuncParam   enI2cParam;
    I2cInitParam  stInitParam;
    HvCalI2c *s_pstSalveI2C = NULL;
    INT32 iLoop = 0;
    USHORT16 usSize     = 0;

    //Hv_Cal_I2C_InitPin(I2C_MODE_SLAVE, CONFIG_AT_I2C_PORT);
    stInitParam.enPort  = 0;
    stInitParam.enMode  = I2C_MODE_SLAVE;
    stInitParam.enSpeed = I2C_SPEED_50K;
    stInitParam.enAddressingMode = I2C_ADDR_7BIT;
    stInitParam.OwnAddress = 0x55;
    stInitParam.bNewInterface = HV_TRUE;
    stInitParam.fI2cCpltCallback = fTestI2CBackR;
    s_pstSalveI2C = Hv_Cal_I2C_Init(&stInitParam);
    Hv_Cal_I2C_SlaveIntReceiveEnable(0);
}

void TaskTestI2CSlaveModePoll(void)
{
    I2cFuncParam   enI2cParam;
    I2cInitParam  stInitParam;
    HvCalI2c *s_pstSalveI2C = NULL;
    INT32 iLoop = 0;
    USHORT16 usSize     = 0;

    //Hv_Cal_I2C_InitPin(I2C_MODE_SLAVE, CONFIG_AT_I2C_PORT);
    stInitParam.enPort  = 0;
    stInitParam.enMode  = I2C_MODE_SLAVE;
    stInitParam.enSpeed = I2C_SPEED_50K;
    stInitParam.enAddressingMode = I2C_ADDR_7BIT;
    stInitParam.OwnAddress = 0x55;
    stInitParam.bNewInterface = HV_TRUE;
    stInitParam.fI2cCpltCallback = fTestI2CBack;


    {
        if (ucI2cReadIndex >= RX_BUF_SIZE)
        {
            ucI2cReadIndex -= RX_BUF_SIZE;
        }
        if (usI2cReceiveIndex > ucI2cReadIndex)
        {
            usSize = usI2cReceiveIndex - ucI2cReadIndex;
        }
        else if (usI2cReceiveIndex < ucI2cReadIndex)
        {
            usSize = RX_BUF_SIZE - ucI2cReadIndex + usI2cReceiveIndex;
        }
        else
        {
            usSize = 0;
        }

        if (usSize > 0)
        {
            HV_LOG_RAW("buf size:  %d[", usSize);
            for (iLoop = 0; iLoop < usSize; iLoop++)
            {
                HV_LOG_RAW("%x ", aucI2CBuf[(ucI2cReadIndex)%RX_BUF_SIZE]);
                aucI2CBuf[(ucI2cReadIndex++)%RX_BUF_SIZE] += 1;
            }
            HV_LOG_RAW("]\n");
            //Hv_Cal_I2C_SlaveTransmit(0, aucI2CBuf, ucI2cRxSize);
            //Hv_Cal_I2C_SlaveIntReceiveEnable(0);
        }
        else
        {
            HV_LOG_RAW("no data:\n");
            Hv_Vos_MSleep(100);
        }
    }

    return;
}

void TaskTestI2CSlaveModeReg(void)
{
    UINT32 ret = 0;
    UINT32 i = 0;
    UINT32 size = 8;
    UCHAR8 pAddrCmd[2] = {0x00, 0x00};
    HvCalI2c *self;
    I2cInitParam initParam;
    I2cFuncParam funcParameter;

    initParam.enPort = (I2cPort)0;
    initParam.enMode = I2C_MODE_SLAVE;
    initParam.enSpeed = TEST_I2C_SPEED;
    initParam.bNewInterface = HV_FALSE;
    initParam.enAddressingMode = I2C_ADDR_7BIT;
    initParam.OwnAddress = 0x55;

    self = Hv_Drv_I2C_Init(&initParam);

        while(1)
        {
            for(i = 0; i < 4; i++) {
                pRxData[i] = 0xaa;
            }

            ret = Hv_Drv_I2C_SlavePollingReceive(self, pRxData, 4, 100);

            Hv_Drv_I2C_SlavePollingTransmit(self, pRxData, 4, 100);

            ret = Hv_Drv_I2C_SlavePollingReceive(self, pRxData, 8, 100);
            {
                for(i = 0; i < 8; i++) {
                    HV_LOGI("I2C-Polling:pRxData[%d]= 0x%02x\n", i, pRxData[i]);
                }
            }
            Hv_Vos_MSleep(100);
        }

    return;
}

static void TaskTestI2CSlaveMode1(UINT32 uiMode)
{
    UINT32 ret = 0;
    UINT32 i = 0;
    UINT32 size = 8;
    UCHAR8 pAddrCmd[2] = {0x00, 0x00};
    HvCalI2c *self;
    I2cInitParam initParam;
    I2cFuncParam funcParameter;

    initParam.enPort = (I2cPort)0;
    initParam.enMode = I2C_MODE_SLAVE;
    initParam.enSpeed = TEST_I2C_SPEED;
    initParam.enAddressingMode = I2C_ADDR_7BIT;
    initParam.OwnAddress = 0x55;

    self = Hv_Drv_I2C_Init(&initParam);

    if (uiMode == 0)
    {
        while(1)
        {
            for(i = 0; i < 4; i++) {
                pRxData[i] = 0;
            }
            ret = Hv_Drv_I2C_SlavePollingReceive(self, pRxData, 4, 100);
            {
                for(i = 0; i < 4; i++) {
                    HV_LOGI("I2C-Polling:pRxData[%d]= 0x%02x\n", i, pRxData[i]);
                }
            }
        }
    }
    else
    {
        while(1)
        {
            ret = Hv_Cal_I2C_SlaveIntReceive(self, pRxData);
            //if (ret == 0)
            {
                for(i = 0; i < 20; i++) {
                    HV_LOGI("I2C-int:pRxData[%d]= 0x%02x\n", i, pRxData[i]);
                }
            //} else {
                HV_LOGI("I2C-int:rx timeout\n");
            }
            Hv_Vos_MSleep(1000);
        }
    }

    return;
}

void TaskTestI2CMasterMode(void)
{
    I2cFuncParam   funcParameter;
    I2cInitParam  stInitParam;
    HvCalI2c *s_pstMasterI2C = NULL;
    UCHAR8 ucTestCount = 15;
    UINT32 size = 0;
    UCHAR8 pAddrCmd[2] = {0x00, 0x00};
    HV_LOG_RAW("TaskTestI2CMasterMode");
    //Hv_Cal_I2C_InitPin(I2C_MODE_MASTER, CONFIG_AT_I2C_PORT);
    stInitParam.enPort  = 0;
    stInitParam.enMode  = I2C_MODE_MASTER;
    stInitParam.enSpeed = I2C_SPEED_50K;
    stInitParam.enAddressingMode = I2C_ADDR_7BIT;
    s_pstMasterI2C = Hv_Cal_I2C_Init(&stInitParam);

    for (UINT32 jLoop = 0; jLoop < ucTestCount; jLoop++)
    {
        size = 5 + jLoop;
        funcParameter.usDevAddress = (0x55);
        funcParameter.pucCmdAddr = pAddrCmd;
        funcParameter.pucData = &pTxData[jLoop];
        funcParameter.usCmdAddrSize = 1;
        funcParameter.usDataSize = size;
        HV_LOG_RAW("send start:");
        Hv_Cal_I2C_MasterPollingTransmit(s_pstMasterI2C, &funcParameter, 100);
        HV_LOG_RAW("buf send data:");
        for (INT32 iLoop = 0; iLoop < size; iLoop++)
        {
            HV_LOG_RAW("%x ", pTxData[jLoop+iLoop]);
        }
        HV_LOG_RAW("\n");
        Hv_Vos_MSleep(2000);
        funcParameter.usDevAddress = (0x55);
        funcParameter.pucCmdAddr = pAddrCmd;
        funcParameter.pucData = aucI2CBuf;
        funcParameter.usCmdAddrSize = TEST_I2C_CMDADDSIZE;
        funcParameter.usDataSize = size;
        Hv_Cal_I2C_MasterPollingReceive(s_pstMasterI2C, &funcParameter, 100);
        HV_LOG_RAW("buf rcv data:");
        for (INT32 iLoop = 0; iLoop < size; iLoop++)
        {
            HV_LOG_RAW("%x ", aucI2CBuf[iLoop]);
        }
        HV_LOG_RAW("\n");

    }
    Hv_Vos_MSleep(5000);
    Hv_Cal_I2C_Cleanup(s_pstMasterI2C);
    s_pstMasterI2C = NULL;
    return;
}

void TaskTestI2CMasterMode2(void)
{
    I2cFuncParam   funcParameter;
    I2cInitParam  stInitParam;
    HvCalI2c *s_pstMasterI2C = NULL;
    UCHAR8 ucTestCount = 15;
    UINT32 size = 0;
    UCHAR8 pAddrCmd[2] = {0x00, 0x00};
    HV_LOG_RAW("TaskTestI2CMasterMode");
    //Hv_Cal_I2C_InitPin(I2C_MODE_MASTER, CONFIG_AT_I2C_PORT);
    stInitParam.enPort  = 0;
    stInitParam.enMode  = I2C_MODE_MASTER;
    stInitParam.enSpeed = I2C_SPEED_50K;
    stInitParam.enAddressingMode = I2C_ADDR_7BIT;
    s_pstMasterI2C = Hv_Cal_I2C_Init(&stInitParam);

    for (UINT32 jLoop = 0; jLoop < ucTestCount; jLoop++)
    {
        size = 5 + jLoop;
        funcParameter.usDevAddress = (0x55);
        funcParameter.pucCmdAddr = pAddrCmd;
        funcParameter.pucData = &pTxData[jLoop];
        funcParameter.usCmdAddrSize = 1;
        funcParameter.usDataSize = size;
        HV_LOG_RAW("send start:");
        Hv_Cal_I2C_MasterPollingTransmit(s_pstMasterI2C, &funcParameter, 100);
        HV_LOG_RAW("buf send data:");
        for (INT32 iLoop = 0; iLoop < size; iLoop++)
        {
            HV_LOG_RAW("%x ", pTxData[jLoop+iLoop]);
        }
        HV_LOG_RAW("\n");
        Hv_Vos_MSleep(2000);
    }
    Hv_Vos_MSleep(5000);
    Hv_Cal_I2C_Cleanup(s_pstMasterI2C);
    s_pstMasterI2C = NULL;
    return;
}
#define REG_LENGTH_16BIT 0

static void TaskTestMI2c(void)
{
    UINT32 ret = 0;
    UINT32 i = 0;
    UINT32 size = 16;
    USHORT16 usAddr = 0;

    Hv_Cal_MI2C_Init();

    for (i = 0; i < size; i++)
    {
        Hv_Cal_MI2C_E2PWriteByte(SLAVE_ADDRESS, usAddr++, REG_LENGTH_16BIT, pTxData[i]);
    }

    usAddr = 0;
    for (i = 0; i < size; i++)
    {
        pRxData[i] = Hv_Cal_MI2C_E2PReadByte(SLAVE_ADDRESS, usAddr++,REG_LENGTH_16BIT);
    }
    for(i = 0; i < size; i++) {
        HV_LOG_RAW("MI2C_Test :pRxData[%d]= 0x%02x\n", i, pRxData[i]);
    }

    ret = HV_WtRdI2cDataCheck(pTxData, pRxData, size);
    HV_LOG_RAW("MI2C_TEST end!ret = %d\n",ret);

}

static int Hv_Shell_I2cTest(int argc, char* argv[])
{
    int i = 0;
    for (i=0; i<34; i++)
    {
        pTxData[i] = i+3;
        pRxData[i] = 0xaa;
    }
    if (argc == 1)
    {
        HV_LOG_RAW("i2c_test p [port] [speed] [7/10bit]");
        HV_LOG_RAW("I2C_SPEED_50K = 0,   I2C_SPEED_80K,    I2C_SPEED_100K,    I2C_SPEED_200K,    I2C_SPEED_400K,");
        HV_LOG_RAW("I2C_ADDR_7BIT = 0,  I2C_ADDR_10BIT\n");
        HV_LOG_RAW("i2c_test [m/s]; test master/slave mode in seperate device.\n");
        HV_LOG_RAW("i2c_test M; test mi2c\n");
        HV_LOG_RAW("i2c_test [T/R/P]; test master send, and slave int receice and poll data mode. usually slave T, master S, slave P.\n");
        HV_LOG_RAW("i2c_test S [mode]; test slave int 0:polling 1:int mode.\n");
        HV_LOG_RAW("i2c_test r; test slave poll t & r register.\n");
        return 0;
    }
    if (0 == strcmp("p", argv[1]))
    {
        TaskTestI2CParam(atoi(argv[2]), atoi(argv[3]), atoi(argv[4]));
    }
    else if (0 == strcmp("m", argv[1]))
    {
        TaskTestI2CMasterMode();
    }
    else if (0 == strcmp("s", argv[1]))
    {
        TaskTestI2CSlaveMode();
    }
    else if (0 == strcmp("T", argv[1]))
    {
        TaskTestI2CMasterMode2();
    }
    else if (0 == strcmp("R", argv[1]))
    {
        TaskTestI2CSlaveModeRceivce();
    }
    else if (0 == strcmp("P", argv[1]))
    {
        TaskTestI2CSlaveModePoll();
    }
    else if (0 == strcmp("r", argv[1]))
    {
        TaskTestI2CSlaveModeReg();
    }
    else if (0 == strcmp("S", argv[1]))
    {
        TaskTestI2CSlaveMode1(atoi(argv[2]));
    }
    else if (0 == strcmp("M", argv[1]))
    {
        TaskTestMI2c();
    }
    else
    {
        HV_LOG_RAW("para not support");
    }
    return 0;
}


SHELL_EXPORT_CMD(i2c_test, Hv_Shell_I2cTest, "i2c_test mode");
/***************************************************************************************************/
/************************************i2c test*********************************************/
/***************************************************************************************************/

/***************************************************************************************************/
/*************************************powermanager start *******************************************/
/***************************************************************************************************/
static int Hv_Shell_SetAutoPoweroff(int argc, char* argv[])
{
    UINT32 uiValue = 0;
    if (2 == argc)
    {
        uiValue = atoi(argv[1]);
    }

    HV_LOGI("set auto poweroff about %d()\n", uiValue);

    Hv_Mw_Power_TimerStart(uiValue);
    return 0;
}

SHELL_EXPORT_CMD(set_auto_poweroff, Hv_Shell_SetAutoPoweroff, "SetAutoPoweroff xx ()");
/***************************************************************************************************/
/*************************************powermanager start *******************************************/
/***************************************************************************************************/

/***************************************************************************************************/
/*************************************led start *******************************************/
/***************************************************************************************************/
#ifdef CONFIG_USER_LED_ON
static int Hv_Shell_Led_Debug(int argc, char* argv[])
{
    LedDeviceId enDevNo = LED_DEVICE_ID_MAX;
    LedChannelId enChNo = LED_CH_ID_MAX;
    LedGlBc stBc = {0};
    LedColor stColor = {0};
     Hv_Drv_Led_Init();
    if (argc >=2)
    {
        if ((0 == strcmp("bc", argv[1])) && (argc == 5))
        {
            stBc.ucRedGbc   = atoi(argv[2]);
            stBc.ucGreenGbc = atoi(argv[3]);
            stBc.ucBlueGbc  = atoi(argv[4]);
            Hv_Drv_Led_SetGlobalBrightness(&stBc);
            Hv_Drv_Led_UpdateColor();
        }
        else if ((0 == strcmp("bcj", argv[1])) && (argc == 4))
        {
            UCHAR8 ucJ = atoi(argv[2]);
            UCHAR8 ucK = atoi(argv[3]);
            Hv_Drv_Led_SetGlobalBrightnessRatio(ucJ, ucK);
            Hv_Drv_Led_UpdateColor();
        }
        else if ((0 == strcmp("adj", argv[1])) && (argc == 3))
        {
            Hv_Drv_Led_AdjustColorEnable(atoi(argv[2]));
        }
        else if ((0 == strcmp("rgb", argv[1])) && (argc == 7))
        {
            enDevNo = atoi(argv[2]);
            enChNo = atoi(argv[3]);
            stColor.ucRed = atoi(argv[4]);
            stColor.ucGreen = atoi(argv[5]);
            stColor.ucBlue = atoi(argv[6]);
            Hv_Drv_Led_ClearColorData();
            if (enChNo == 0xFF)
            {
                for (UINT32 j = 0; j < TLC5971_PIXELS_PER_DEVICE; j++)
                {
                    Hv_Drv_Led_FillColorData(enDevNo, j, &stColor);
                }
            }
            else
            {
                Hv_Drv_Led_FillColorData(enDevNo, enChNo, &stColor);
            }
            Hv_Drv_Led_UpdateColor();
        }
        else if (0 == strcmp("marq", argv[1]))
        {
            INT32 iCnt = 10;
            stBc.ucRedGbc   = 64;
            stBc.ucGreenGbc = 64;
            stBc.ucBlueGbc  = 64;
            stColor.ucRed = 128;
            stColor.ucGreen = 128;
            stColor.ucBlue = 128;
            Hv_Drv_Led_SetGlobalBrightness(&stBc);
            while (iCnt >= 0)
            {
                iCnt--;
                for (UINT32 i = 0; i < HV_BOARD_CONFIG_LED_IC_NUM; i++)
                {
                    for (UINT32 j = 0; j < TLC5971_PIXELS_PER_DEVICE; j++)
                    {
                        Hv_Drv_Led_ClearColorData();
                        Hv_Drv_Led_FillColorData(i, j, &stColor);
                        Hv_Drv_Led_UpdateColor();
                        Hv_Vos_Delayus(500000);
                    }
                }
            }
            Hv_Drv_Led_ClearColorData();
            Hv_Drv_Led_UpdateColor();
        }
        else if (0 == strcmp("dump", argv[1]))
        {
            Hv_Drv_Led_DumpDataBuffer();
        }
    }
    return 0;
}

SHELL_EXPORT_CMD(led_debug, Hv_Shell_Led_Debug, "Debug Led");
#endif
/***************************************************************************************************/
/*************************************led end *******************************************/
/***************************************************************************************************/
extern VOID Hv_Drv_Flash_ProtectDisable(VOID);
extern VOID Hv_Drv_Flash_Info(VOID);
static int Hv_Shell_Flash_Degbug(int argc, char* argv[])
{
    if (1 == argc)
    {
        HV_LOGI("flash_debug [wp/info]\n");
        return 0;
    }
    if (0 == strcmp("wp", argv[1]))
    {
        Hv_Drv_Flash_ProtectDisable();
    }
    else if (0 == strcmp("info", argv[1]))
    {
        Hv_Drv_Flash_Info();
    }
    else
    {}
    return 0;
}
SHELL_EXPORT_CMD(flash_debug, Hv_Shell_Flash_Degbug, "flash debug");

static int Hv_Shell_ledctl(int argc, char* argv[])
{
    if (1 == argc)
    {
        HV_LOGI("ledctl [r] [0-5]\n");
        HV_LOGI("ledctl [b] [0/1]\n");
        HV_LOGI("ledctl [p] [0-255]\n");
        return 0;
    }

    if (0 == strcmp("r", argv[1]))
    {
        Hv_Mw_Led_SetRedLedMode(atoi( argv[2]));
    }
    else if (0 == strcmp("b", argv[1]))
    {
        Hv_Mw_Led_SetBlueLed(atoi( argv[2]));
    }
    else if (0 == strcmp("p", argv[1]))
    {
        Hv_Mw_Led_SetBlueLedBright(atoi( argv[2]));
    }
    return 0;
}
SHELL_EXPORT_CMD(ledctl, Hv_Shell_ledctl, "ledctl");


#define ISPRAM_ADDR 0x12010000
#define DSPRAM_ADDR 0x12000000
#define SPRAM_TEST_PATTERN 0x55
#define SPRAM_SIZE 0x8000

static int test_ram_dma_check(UCHAR8* SrcAddr, UCHAR8* DstAddr, UINT32 Size)
{
    unsigned int i = 0;
    HV_LOGV("test_ram_dma_check enter\r\n");
    for (i=0; i<Size; i++)
    {
        if (*SrcAddr != *DstAddr)
        {
           HV_LOGI("CHECK ERROR!!! index:[%x,%x] src:[%x,%x], dst[%x,%x]\n", i, Size, SrcAddr, *SrcAddr, DstAddr, *DstAddr);
           return -1;
        }
        SrcAddr++;
        DstAddr++;
    }
    HV_LOGV("test_ram_dma_check over\r\n");
    return 0;
}

static int test_spram_one(int type, char pattern)
{

    unsigned int srcaddr1 = 0x83000000;
    unsigned int dstaddr2 = 0x12000000;
    unsigned int dstaddr3 = 0x83100000;
    unsigned int size = 0x400;
    unsigned int loop = SPRAM_SIZE/size;
    int ret = 0;
    int i,j;

    HV_MEMSET((char*)srcaddr1, SPRAM_TEST_PATTERN, SPRAM_SIZE);

    DmaSelf* self = NULL;
    DmaInitParam InitParam ;
    HV_MEMSET(&InitParam, 0, sizeof(DmaInitParam));
    InitParam.PortChannelNum = DMA_PORT1_CHANNEL1;
    InitParam.Application = DMA_APPLI_MEM;
    InitParam.transType = DMA_TYPE_SINGLE;
    InitParam.XferCpltCallback = NULL;

    DmaSelf* self2 = NULL;
    DmaInitParam InitParam2 ;
    HV_MEMSET(&InitParam2, 0, sizeof(DmaInitParam));
    InitParam2.PortChannelNum = DMA_PORT1_CHANNEL2;
    InitParam2.Application = DMA_APPLI_MEM;
    InitParam2.transType = DMA_TYPE_SINGLE;
    InitParam2.XferCpltCallback = NULL;

    if (0 == type)
    {
        dstaddr2 = ISPRAM_ADDR;
        // spr enable
        ret = 0;
        asm __volatile__ ("mfc0 $10, $26,0");//t2=cp0_errctrl 26,0
        asm __volatile__ ("move %0,$10\n\t":"=g"(ret));
        ret |= 1 << 28;//spr
        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));//t2=ret
        asm __volatile__ ("mtc0 $10,$26,0\n\t");
        ret = 0;
        asm __volatile__ ("mfc0 $10, $26,0");//t2=cp0_errctrl 26,0
        asm __volatile__ ("move %0,$10\n\t":"=g"(ret));
        HV_LOGV("cp0_errctrl %x\n", (unsigned int)ret);
        ret = 0;
        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));
        asm __volatile__ ("cache 0x4,0($10)\n\t");
        asm __volatile__ ("mfc0 $10, $28,0");//t2=C0_ITAGLO
        asm __volatile__ ("move %0,$10\n\t":"=g"(ret));
        HV_LOGV("C0_ITAG %x\n", (unsigned int)ret);

        HV_LOGV("ispram!\n");
        // load the address of the ISPram
        ret = 0x12010000;
        ret |= 1<<7;
        ret |= 1<<11;
        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));
        asm __volatile__ ("mtc0  $10,$28,0\n\t");//C0_ITAGLO
        ret = 0;
        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));//t2=0
        asm __volatile__ ("cache 0x8,0($10)\n\t");

        ret = 0;
        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));
        asm __volatile__ ("mtc0  $10,$28,0\n\t");//C0_ITAGLO

        asm __volatile__ ("mfc0 $10, $26,0");//t2=cp0_errctrl 26,0
        asm __volatile__ ("move %0,$10\n\t":"=g"(ret));
        HV_LOGV("cp0_errctrl %x\n", (unsigned int)ret);

        ret = 0;
        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));
        asm __volatile__ ("cache 0x4,0($10)\n\t");
        asm __volatile__ ("nop\n\t");
        asm __volatile__ ("nop\n\t");
        asm __volatile__ ("nop\n\t");
        asm __volatile__ ("nop\n\t");

        asm __volatile__ ("mfc0 $10, $28,0");//t2=C0_ITAG
        asm __volatile__ ("move %0,$10\n\t":"=g"(ret));
        HV_LOGV("C0_ITAG %x\n", (unsigned int)ret);

        InitParam.masterMode = DMA_MASTER_MODE_ISPRAM_WRITE;
        self = Hv_Cal_Dma_ChannelInit(&InitParam);

        InitParam2.masterMode = DMA_MASTER_MODE_ISPRAM_READ;
        self2 = Hv_Cal_Dma_ChannelInit(&InitParam2);

        HV_MEMSET((char*)srcaddr1, pattern, SPRAM_SIZE);
    }
    else  if (1 == type)
    {
        dstaddr2 = DSPRAM_ADDR;
        // spr enable
        ret = 0;
        asm __volatile__ ("mfc0 $10, $26,0");//t2=cp0_errctrl 26,0
        asm __volatile__ ("move %0,$10\n\t":"=g"(ret));
        HV_LOGV(">>> errctrl:\n");
        HV_LOGV("cp0_errctrl %x\n", (unsigned int)ret);
        ret |= 1 << 28;//spr

        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));//t2=ret
        asm __volatile__ ("mtc0 $10,$26,0\n\t");
        ret = 0;
        asm __volatile__ ("mfc0 $10, $26,0");//t2=cp0_errctrl 26,0
        asm __volatile__ ("move %0,$10\n\t":"=g"(ret));
        HV_LOGV("cp0_errctrl %x\n", (unsigned int)ret);

        ret = 0;
        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));
        asm __volatile__ ("cache 0x5,0($10)\n\t");
        asm __volatile__ ("nop\n\t");
        asm __volatile__ ("nop\n\t");
        asm __volatile__ ("nop\n\t");
        asm __volatile__ ("nop\n\t");
        asm __volatile__ ("mfc0 $10, $28,2");//t2=C0_DTAG
        asm __volatile__ ("move %0,$10\n\t":"=g"(ret));
        HV_LOGV("C0_DTAG %x\n", (unsigned int)ret);

        HV_LOGV("dspram!\n");

        // load the address of the DSPram
        ret = 0x12000000;
        ret |= 1<<7;
        ret |= 1<<11;
        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));
        asm __volatile__ ("mtc0  $10,$28,2\n\t");//C0_DTAG
        ret = 0;
        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));//t2=0
        asm __volatile__ ("cache 0x9,0($10)\n\t");

        // load the address of the DSPram
        ret = 0x10160000;
        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));
        asm __volatile__ ("mtc0  $10,$28,2\n\t");//C0_DTAG

        ret = 0;
        asm __volatile__ ("move $10, %0\n\t"::"r"(ret));
        asm __volatile__ ("cache 0x5,0($10)\n\t");
        asm __volatile__ ("nop\n\t");
        asm __volatile__ ("nop\n\t");
        asm __volatile__ ("nop\n\t");
        asm __volatile__ ("nop\n\t");

        asm __volatile__ ("mfc0 $10, $28,2");//t2=C0_DTAG
        asm __volatile__ ("move %0,$10\n\t":"=g"(ret));
        HV_LOGV("C0_DTAG %x\n", (unsigned int)ret);

        InitParam.masterMode = DMA_MASTER_MODE_DSPRAM_WRITE;
        self = Hv_Cal_Dma_ChannelInit(&InitParam);

        InitParam2.masterMode = DMA_MASTER_MODE_DSPRAM_READ;
        self2 = Hv_Cal_Dma_ChannelInit(&InitParam2);

        HV_MEMSET((char*)srcaddr1, pattern, SPRAM_SIZE);
    }
    else
    {
        HV_LOGI("wrong param\n");
    }

    for (i=0;i<loop;i++)
    {
        Hv_Cal_Dma_MemMove(self, (UINT32)(srcaddr1+size*i), (UINT32)(dstaddr2+size*i), size);
        Hv_Vos_MSleep(20);
        Hv_Cal_Dma_MemMove(self2, (UINT32)(dstaddr2+size*i), (UINT32)(dstaddr3+size*i), size);
        Hv_Vos_MSleep(20);
    }
    test_ram_dma_check((UCHAR8*)(srcaddr1), (UCHAR8*)(dstaddr3), SPRAM_SIZE);

    Hv_Cal_Dma_CleanUp(self);
    Hv_Cal_Dma_CleanUp(self2);
    return 0;
}

static int Hv_Shell_Spram_Test(int argc, char* argv[])
{
    char pattern = 1;
    char Loop = 1;

    if (1 == argc)
    {
        HV_LOGI("spramtest [I/D/auto]\n");
        return 0;
    }

    if (0 == strcmp("I", argv[1]))
    {
        test_spram_one(0, SPRAM_TEST_PATTERN);
    }
    else  if(0 == strcmp("D", argv[1]))
    {
        test_spram_one(1, SPRAM_TEST_PATTERN<<1);
    }
    else  if(0 == strcmp("auto", argv[1]))
    {
        for (pattern=0xff; pattern>0;pattern--)
        {
            HV_LOGI("@@test isparam %2x\n", pattern);
            test_spram_one(0, pattern);
        }
        for (pattern=0xff; pattern>0;pattern--)
        {
            HV_LOGI("@@test dsparam %2x\n", pattern);
            test_spram_one(1, pattern);
        }
    }
    else
    {
    }

    return 0;
}
SHELL_EXPORT_CMD(spramtest, Hv_Shell_Spram_Test, "spramtest");

static INT32 Hv_Shell_ShowIpStat(INT32 iArgc, CHAR8 *Argv[])
{
    HV_R32_DECL_VAR();

    /* gpio */
    HV_LOGI("gpio standby: %x\n", HV_R32(0x11008190));
    HV_LOGI("gpio main in: %x %x\n", HV_R32(0x11086028), HV_R32(0x1108602c));
    HV_LOGI("gpio main out: %x %x\n", HV_R32(0x11086060), HV_R32(0x11086064));
    HV_LOGI("gpio main oe: %x %x\n", HV_R32(0x11086068), HV_R32(0x1108606c));
    /* hdmi */
    HV_LOGI("hdmi cable: %x %x\n", Hv_Cal_HdmiRx_GetCableStatus(0), Hv_Cal_HdmiRx_GetCableStatus(1));
    HV_LOGI("hdmi cable connect: %x %x\n", Hv_Cal_HdmiRx_GetCableConnectStatus(0), Hv_Cal_HdmiRx_GetCableConnectStatus(1));
    /* dp */
    HV_LOGI("dp cable: %x %x\n", Hv_Cal_DpRx_DetectCable(0), Hv_Cal_DpRx_DetectCable(1));
    HV_LOGI("dp link state: %x %x\n", Hv_Cal_DpRx_GetLtState(0), Hv_Cal_DpRx_GetLtState(1));
    HV_LOGI("dp lane clk: %x %x\n", Hv_Cal_DpRx_GetLaneClk(0), Hv_Cal_DpRx_GetLaneClk(1));
    /* channel dpu*/
    Hv_Shell_ShowDpuConfig(0, NULL);
    /* tx */
    /* od */
    HV_LOGI("od enable: %x\n", HV_R32(0x11051A00)&BIT_14);
    HV_LOGI("od cpr enable: %x\n", HV_R32(0x11051940)&BIT_0);
    HV_LOGI("od cpr crc enable: %x\n", HV_R32(0x11051990)&BIT_2);
    HV_LOGI("od cpr crc fail: %x\n", HV_R32(0x110519E0)&BIT_4);
    /* ld */
    return 0;
}
SHELL_EXPORT_CMD(ip_stat, Hv_Shell_ShowIpStat, "show ip status");

UCHAR8 RdData[4] = {0};
UCHAR8 SpiCmd[4] = {0x9f,0x00,0x00,0x00};
UCHAR8 SpiData[256] = {0};
SpiSelf* s_Spiself = NULL;

SpiSelf* Test_Spi_Master_Init(int uiBaudrate)
{

    SpiInitParam InitParam = {0};

    InitParam.enDataSize = SPI_BITWIDTH_32;
    InitParam.enMode = SPI_MODE_MASTER;
    InitParam.enDirection = SPI_DIRECTION_TXRX;
    InitParam.enClkPolarity = SPI_CLKPOLARITY_LOW;
    InitParam.enClkPhase = SPI_CLKPHASE_1EDGE;
    InitParam.enCsCtlMode = SPI_CSMODE_HARDWARE;

    s_Spiself = Hv_Drv_Spi_Init(&InitParam);
    Hv_Drv_Spi_SetBaudRate(s_Spiself, uiBaudrate);
    return s_Spiself;
}

void FLASH_WriteEnable(void)
{
    SpiCmd[0] = 0x05;
    RdData[1] = 0x1;
    Hv_Drv_Spi_SetDirection(s_Spiself, SPI_DIRECTION_TXRX);
    Hv_Drv_Spi_SetBitsWidth(s_Spiself, SPI_BITWIDTH_16);
    while(RdData[1]&0x1)
    {
        Hv_Drv_Spi_PollingReceive(s_Spiself, SpiCmd,2, RdData, HV_SPI_NO_DUMMY, HV_SPI_TIMEOUT);
    }
    HV_LOG_RAW("wait busy ok.");


    SpiCmd[0] = 0x06;
    Hv_Drv_Spi_SetDirection(s_Spiself, SPI_DIRECTION_TX);
    Hv_Drv_Spi_SetBitsWidth(s_Spiself, SPI_BITWIDTH_8);
    Hv_Drv_Spi_PollingTransmit(s_Spiself, SpiCmd, 1, NULL, 0, HV_SPI_TIMEOUT);
    HV_LOG_RAW("write enable ok.");
}

static int Hv_Shell_SpiTest(int argc, char* argv[])
{
    int i = 0;
    for (i=0; i<256; i++)
    {
        SpiData[i] = i;
    }
    if (argc == 1)
    {
        HV_LOG_RAW("test_spi [speed]");
        HV_LOG_RAW("    SPI_DIVRATIO_8       = 8,  ...  SPI_DIVRATIO_16      = 16(191/16), ...   SPI_DIVRATIO_512     = 512,");
        return 0;
    }
    Test_Spi_Master_Init(atoi(argv[1]));
    if (NULL == s_Spiself)
    {
        HV_LOG_RAW("test_spi init fail.");
    }
    SpiCmd[0] = 0x9f;
    Hv_Drv_Spi_SetDirection(s_Spiself, SPI_DIRECTION_TXRX);
    Hv_Drv_Spi_SetBitsWidth(s_Spiself, SPI_BITWIDTH_32);
    Hv_Drv_Spi_PollingReceive(s_Spiself, SpiCmd,4,RdData, 0, HV_SPI_TIMEOUT);
    HV_LOG_RAW("RdId addr is 0x%x.\n",(((UINT32)RdData[3]) | ((UINT32)RdData[2] << 8) | (((UINT32)RdData[1]) << 16) | (((UINT32)RdData[0]) << 24)));

    FLASH_WriteEnable();
    SpiCmd[0] = 0x20;
    SpiCmd[1] = 0x00;
    SpiCmd[2] = 0x01;
    SpiCmd[3] = 0x00;
    Hv_Drv_Spi_SetDirection(s_Spiself, SPI_DIRECTION_TX);
    Hv_Drv_Spi_SetBitsWidth(s_Spiself, SPI_BITWIDTH_8);
    Hv_Drv_Spi_PollingTransmit(s_Spiself, SpiCmd, 4, NULL, 0, HV_SPI_TIMEOUT);
    HV_LOG_RAW("send erase ok.");

    FLASH_WriteEnable();
    /* write start 0x000100*/
    SpiCmd[0] = 0x2;
    SpiCmd[1] = 0x00;
    SpiCmd[2] = 0x01;
    SpiCmd[3] = 0x00;
    Hv_Drv_Spi_SetBitsWidth(s_Spiself, SPI_BITWIDTH_8);
    Hv_Drv_Spi_PollingTransmit(s_Spiself, SpiCmd,4,SpiData, 256, HV_SPI_TIMEOUT);
    for (i=0; i<256; i++)
    {
        SpiData[i] = 0;
    }
    HV_LOG_RAW("write ok.");
    Hv_Vos_MSleep(1000);

    /* read start 0x000100*/
    SpiCmd[0] = 0x3;
    SpiCmd[1] = 0x00;
    SpiCmd[2] = 0x01;
    SpiCmd[3] = 0x00;
    Hv_Drv_Spi_SetBitsWidth(s_Spiself, SPI_BITWIDTH_8);
    Hv_Drv_Spi_SetDirection(s_Spiself, SPI_DIRECTION_TXRX);
    Hv_Drv_Spi_PollingReceive(s_Spiself, SpiCmd,4,SpiData, 256, HV_SPI_TIMEOUT);
    HV_LOG_RAW("receive ok.");

    for (i=0; i<256; i++)
    {
        if (SpiData[i] != i)
        {
            HV_LOG_RAW("check error. [%d] read %x", i, SpiData[i]);
        }
    }
    HV_LOG_RAW("test over.");
    Hv_Drv_Spi_Cleanup(s_Spiself);
    s_Spiself = NULL;
    return 0;
}
SHELL_EXPORT_CMD(test_spi, Hv_Shell_SpiTest, "spi test");
/***************************************************************************************************/
/*************************************USB OTA Start *******************************************/
/***************************************************************************************************/
#if (defined(CONFIG_USER_USB_OTA_ON) || defined(CONFIG_USER_USB_BILLBOARD_ON))
#include "hv_mw_UsbTask.h"
#include "hv_drv_UsbCoreUtils.h"
#include "hv_comm_Event.h"
#include "hv_drv_UsbComm.h"
#include "hv_comm_Ota.h"

int Hv_Shell_UsbOtaDebug(int argc, char* argv[])
{
    static UCHAR8 ucPingPang = 0;
    
    if (argc >= 2)
    {
        if (0 == strcmp("5", argv[1]))
        {
            HV_LOGI("MemoryRemaining: 0x%x\n",Hv_Vos_MemoryRemaining());
        }
#ifdef CONFIG_USER_USB_OTA_ON
        else if (0 == strcmp("1", argv[1]))
        {
            Hv_Drv_USB_SendEventToUsbQueue(USB_EVENT_NORMAL_UPGRADE, 0);
        }
        else if (0 == strcmp("2", argv[1]))
        {
            Hv_Drv_USB_SendEventToUsbQueue(USB_EVENT_UPGRADE_CONFIRM, 0);
        }
        else if (0 == strcmp("3", argv[1]))
        {
            Hv_Drv_USB_SendEventToUsbQueue(USB_EVENT_UPGRADE_CANCEL, 0);
        }
        else if (0 == strcmp("4", argv[1]))
        {
            Hv_Drv_USB_SendEventToUsbQueue(USB_EVENT_FORCE_UPGRADE, 0);
        }
        else if (0 == strcmp("6", argv[1]))
        {
            if(0 == strcmp("0", argv[2]))
            {
                Hv_Mw_UsbHost_TaskStop();
            }
            else if(0 == strcmp("1", argv[2]))
            {
                Hv_Mw_UsbHost_TaskStartInit();
            }
            else
            {
            }
        }
        else if(0 == strcmp("7", argv[1]))
        {
            //UCHAR8* partitions[] = {"SBLKCODE", "SBLKLOGO", "SBLKPQDA"};
            //UCHAR8  numPartitions = sizeof(partitions) / sizeof(partitions[0]);
            //Hv_Mw_USB_StartOta(3, partitions, OTA_MODE_NORMAL);
            UCHAR8 cnt = atoi(argv[2]);
            UCHAR8* args[cnt];
            for (int i = 0; i < cnt; i++)
            {
                args[i] = (UCHAR8*)argv[i + 3];
            }
            Hv_Mw_USB_StartOta(cnt, args, OTA_MODE_NORMAL);
        }
#endif

#ifdef CONFIG_USER_USB_BILLBOARD_ON
        else if (0 == strcmp("8", argv[1]))
        {
            if(0 == strcmp("0", argv[2]))
            {
                Hv_Mw_UsbBillboard_TaskStop();
                
            }
            else if(0 == strcmp("1", argv[2]))
            {
                Hv_Drv_USB_SendEventToUsbQueue(USB_EVENT_START_BILLBOARD, 0);
            }
        }
#endif
#if defined(CONFIG_USER_USB_OTA_ON) && defined(CONFIG_USER_USB_BILLBOARD_ON)
        else if (0 == strcmp("9", argv[1]))
        {
            while(1)
            {
                if(0 == ucPingPang)
                {
                    ucPingPang++;
                    HV_LOGI("host start ---->");
                    Hv_Drv_USB_SendEventToUsbQueue(USB_EVENT_NORMAL_UPGRADE, 0);
                }
                else
                {
                    HV_LOGI("billboard start ---->");
                    Hv_Drv_USB_SendEventToUsbQueue(USB_EVENT_START_BILLBOARD, 0);
                    ucPingPang = 0;
                }
                Hv_Vos_MSleep(10000);
            }
        }
#endif
        else if (0 == strcmp("10", argv[1]))
        {
            UCHAR8 aucCodeCRC[OTA_SBLK_CRC_LEN] = {0};
            char   *endptr = NULL;
            UINT32 uiAddr = 0;
            UINT32 uiCrc = strtoul(argv[3], &endptr, 0);
            aucCodeCRC[0] = (uiCrc >> 24) & 0xFF;
            aucCodeCRC[1] = (uiCrc >> 16) & 0xFF;
            aucCodeCRC[2] = (uiCrc >> 8) & 0xFF;
            aucCodeCRC[3] = uiCrc & 0xFF;
            uiAddr = strtoul(argv[2], &endptr, 0);
            Hv_Comm_OTA_UpdatePartitionCrcByAddr(aucCodeCRC, OTA_SBLK_CRC_LEN, uiAddr);
        }
        else if (0 == strcmp("11", argv[1]))
        {
            PartitionSBLKInfo stPartInfo;
            char   *endptr = NULL;
            UINT32 uiAddr  = strtoul(argv[2], &endptr, 0);
            Hv_Comm_OTA_GetPartitionInfoByStartAddr(uiAddr, &stPartInfo);
            HV_PRINTF("SBLK Name: ");
            for (UINT32 k = 0; k < SBLK_MAGIC_STRING_LENGTH; k++)
            {
                HV_PRINTF("%c", stPartInfo.ucSBLKName[k]);
            }
            HV_PRINTF("\n");
            HV_LOG_INFO(DEFAULT, "ValidLen:0x%08x, Addr:0x%08x, Crc:0x%08x, Total:0x%08x, ", stPartInfo.uiValidLen, stPartInfo.uiStartAddr, stPartInfo.uiCRC, stPartInfo.uiTotalLen);
            
        }
        else
        {

        }
    }
    else
    {
        HV_LOGI("usb_test 1-start find ota file\n");
        HV_LOGI("usb_test 2-confirm\n");
        HV_LOGI("usb_test 3-cancel\n");
        HV_LOGI("usb_test 4-force ota\n");
        HV_LOGI("usb_test 5-printf memory remains\n");
        HV_LOGI("usb_test 6 [flag]-1:usb task start, 0:usb task stop\n");
        HV_LOGI("usb_test 7 [Cnt] [Name]-start ota with partition name, eg: usb_test 7 3 SBLKLOGO SBLKCODE SBLKPQDA\n");
        HV_LOGI("usb_test 8 [flag]-1:start billboard, 0:stop billboard\n");
        HV_LOGI("usb_test 9-Pressure Test: Switch Billboard and Host\n");
        HV_LOGI("usb_test 10 [PartAddr] [CRC]-update partition crc by addr. eg: usb_test 10 0x00009000 0x12345678\n");
        HV_LOGI("usb_test 11 [PartAddr]-get partition info by addr. eg: usb_test 11 0x00009000\n");
    }
    
    return 0;
}
HV_SHELL_EXPORT_CMD(usb_test, Hv_Shell_UsbOtaDebug, "Usb Test Commands");

#endif
/***************************************************************************************************/
/*************************************USB OTA end *******************************************/
/***************************************************************************************************/

