// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2020 MediaTek Inc.
 *
 */


#ifdef CONFIG_MTK_INTERNAL_HDMI_SUPPORT

#include "hdmi_ctrl.h"
#include "hdmiedid.h"
#include "hdmicmd.h"
#include "hdmi_ca.h"
#include "hdmictrl.h"
#include <linux/debugfs.h>
#include "hdmitx.h"
#include "hdmihdcp.h"

unsigned int debugonoff;
unsigned int _u4VideoRes, _u4Aspect, _u4ColorSpace;

unsigned int pdRegsP2I480[] = {
	0x1740, 0x20BE0805,
	0x1744, 0x00290359,
	0x1748, 0x00290359,
	0x174c, 0x00580058,
	0x1750, 0x0010021D,
	0x1754, 0x00150107,
	0x1758, 0x011C020E,
	0x1770, 0x00000000,
	0x1774, 0x00000000,
	0x1778, 0x11301130,
	0x177c, 0x00808010,

};

unsigned int pdRegs480i_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0x00009420,
	0x10a0, 0x00690338,
	0x10a4, 0x002B020A,
	0x10a8, 0x002B020A,
	0x10d4, 0x00000000,
	0x1018, 0x00160000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs480p_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0x00009f20,
	0x10a0, 0x00650334,
	0x10a4, 0x002b020a,
	0x10a8, 0x002b020a,
	0x10d4, 0x00000000,
	0x1018, 0x00160000,
	0x10f4, 0x00000001,
	0x10f8, 0x00000000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegsP2I576[] = {
	0x1740, 0x20BE0805,
	0x1744, 0x00290359,
	0x1748, 0x00290359,
	0x174c, 0x00580058,
	0x1750, 0x002A0461,
	0x1754, 0x00160137,
	0x1758, 0x014F0270,
	0x1770, 0x00000000,
	0x1774, 0x00000000,
	0x1778, 0x11301130,
	0x177c, 0x00808010,

};

unsigned int pdRegs576i_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0xc0009420,
	0x10a0, 0x00740343,
	0x10a4, 0x002d026c,
	0x10a8, 0x002d026c,
	0x10d4, 0x00000000,
	0x1018, 0x00160000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs576p_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0xc0009420,
	0x10a0, 0x006d033c,
	0x10a4, 0x002d026c,
	0x10a8, 0x002d026c,
	0x10d4, 0x00000000,
	0x1018, 0x00160000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs720p60_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0x0000f120,
	0x10a0, 0x00e305e2,
	0x10a4, 0x001a02e9,
	0x10a8, 0x001a02e9,
	0x10d4, 0x00000000,
	0x1018, 0x00130000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs720p50_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0xc000f120,
	0x10a0, 0x00e205e1,
	0x10a4, 0x001a02e9,
	0x10a8, 0x001a02e9,
	0x10d4, 0x00000000,
	0x1018, 0x00130000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs1080p60_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0x0000df20,
	0x10a0, 0x00970816,
	0x10a4, 0x002b0464,
	0x10a8, 0x002b0464,
	0x10d4, 0x00000000,
	0x1018, 0x001d0000,
	0x10f4, 0x00000000,
	0x10f8, 0x00000000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};


unsigned int pdRegs1080p50_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0xc000d420,
	0x10a0, 0x009a0819,
	0x10a4, 0x00290460,
	0x10a8, 0x00290460,
	0x10d4, 0x00000000,
	0x1018, 0x001d0000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegsP2I1080I50[] = {
	0x1740, 0x20BE0805,
	0x1744, 0x00660856,
	0x1748, 0x00660856,
	0x174c, 0x00CB00CB,
	0x1750, 0x00280462,
	0x1754, 0x00140231,
	0x1758, 0x02470464,
	0x1770, 0x00000000,
	0x1774, 0x00000000,
	0x1778, 0x11301130,
	0x177c, 0x00808010,

};

unsigned int pdRegsP2I1080I60[] = {
	0x1740, 0x20BE0805,
	0x1744, 0x00660856,
	0x1748, 0x00660856,
	0x174c, 0x00Cd00Cd,
	0x1750, 0x00280462,
	0x1754, 0x00140231,
	0x1758, 0x02470464,
	0x1770, 0x00000000,
	0x1774, 0x00000000,
	0x1778, 0x11301130,
	0x177c, 0x00808010,

};

unsigned int pdRegs1080i60_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0x0000d420,
	0x10a0, 0x00A0081F,
	0x10a4, 0x002a0461,
	0x10a8, 0x002a0461,
	0x10d4, 0x00000000,
	0x1018, 0x001d0000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs1080i50_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0xc000d420,
	0x10a0, 0x009a0819,
	0x10a4, 0x00290460,
	0x10a8, 0x00290460,
	0x10d4, 0x00000000,
	0x1018, 0x001d0000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs720p3d60_fmtsetting[] = {
	0x1084, 0x86725dcb,
	0x1094, 0x0000f420,
	0x10a0, 0x01650664,
	0x10a4, 0x001e02ed,
	0x10a8, 0x001e02ed,
	0x10d4, 0x867202ee,
	0x1018, 0x00130000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs1080i3d60_fmtsetting[] = {
	0x1084, 0x88988cab,
	0x1094, 0x00005120,
	0x10a0, 0x00c10840,
	0x10a4, 0x00150230,
	0x10a8, 0x02480463,
	0x10d4, 0x672002ee,
	0x1018, 0x001d0000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs1080p3d24_fmtsetting[] = {
	0x1084, 0x8abe8cab,
	0x1094, 0xc000d820,
	0x10a0, 0x00c10840,
	0x10a4, 0x002a0461,
	0x10a8, 0x002a0461,
	0x10d4, 0x8abe0465,
	0x1018, 0x001d0000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs2160p30_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0x0000df20,
	0x10a0, 0x01811080,
	0x10a4, 0x005308c2,
	0x10a8, 0x005308c2,
	0x10d4, 0x913008ca,
	0x1018, 0x003b0000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs2160p50_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0x0000df20,
	0x10a0, 0x01811080,
	0x10a4, 0x005308c2,
	0x10a8, 0x005308c2,
	0x10d4, 0x94a008ca,
	0x1018, 0x003b0000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs2160p60_fmtsetting[] = {
	0x1084, 0x00000000,
	0x1094, 0x0000df20,
	0x10a0, 0x01811080,
	0x10a4, 0x005308c2,
	0x10a8, 0x005308c2,
	0x10d4, 0x913008ca,
	0x1018, 0x003b0000,
	0x10f4, 0x00000001,
	0x10f8, 0x007f0000,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000403,
	0x10ac, 0x00000003,
};

unsigned int pdRegs480i_rgb2hdmi[] = {
	0x1800, 0x02100D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x037C0306,
	0x1820, 0x00EF068E,
	0x1824, 0x00160105,
	0x1828, 0x011D020C,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x00EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x00010018,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000000,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x0000008C,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000000,
};

unsigned int pdRegs576i_rgb2hdmi[] = {
	0x1800, 0x02100D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x037E0003,
	0x1820, 0x010906A8,
	0x1824, 0x00170136,
	0x1828, 0x0150026F,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x00EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x00010014,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000000,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x00000134,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000000,
};


unsigned int Regs480p_rgb2hdmi[] = {
	0x1800, 0x00000D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x033e060c,
	0x1820, 0x007b034a,
	0x1824, 0x002b020a,
	0x1828, 0x002b020a,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xebff0000,
	0x1854, 0xeb001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x80EB0100,
	0x1864, 0x00EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1890, 0xec3f8080,
	0x1894, 0xfc06f60f,
	0x1898, 0x7505bac4,
	0x189c, 0x00000000,
	0x18a0, 0xf4006080,
	0x18a4, 0xffcb07f7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18B0, 0x06b4020D,
	0x18B4, 0x00010012,
	0x18B8, 0xd4006400,
	0x18Bc, 0x00004100,
	0x18C0, 0x00000001,
	0x18d0, 0x0000040c,
	0x18d4, 0x00000008,
};

unsigned int pdRegs576p_rgb2hdmi[] = {
	0x1800, 0x02000D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x03400005,
	0x1820, 0x00850354,
	0x1824, 0x002D026C,
	0x1828, 0x002D026C,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x00EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x00010011,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x00000011,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000000,
};

unsigned int pdRegs720p60_rgb2hdmi[] = {
	0x1800, 0x02000D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x00280005,
	0x1820, 0x01050604,
	0x1824, 0x001A02E9,
	0x1828, 0x001A02E9,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x40EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x00010010,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x000003A4,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000008,
};


unsigned int pdRegs720p50_rgb2hdmi[] = {
	0x1800, 0x02000D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x00280005,
	0x1820, 0x01050604,
	0x1824, 0x001A02E9,
	0x1828, 0x001A02E9,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x40EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x00010010,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x0000012C,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000000,
};


unsigned int Regs1080p60_rgb2hdmi[] = {
	0x1800, 0x00000d4d,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x002c0005,
	0x1820, 0x00C10840,
	0x1824, 0x202A0461,
	0x1828, 0x002A0461,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00000000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xebff0000,
	0x1854, 0xeb001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x80eb0100,
	0x1864, 0x40eb0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1890, 0xec3f8080,
	0x1894, 0xfc06f60f,
	0x1898, 0x7505bac4,
	0x189c, 0x00000000,
	0x18a0, 0xf4006080,
	0x18a4, 0xffcb07f7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18B0, 0x06b4020D,
	0x18B4, 0x00050022,
	0x18B8, 0xd4006400,
	0x18Bc, 0x00004100,
	0x18C0, 0x00000001,
	0x18d0, 0x0000018a,
	0x18d4, 0x00000008,
};


unsigned int Regs1080p50_rgb2hdmi[] = {
	0x1800, 0x02000D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x002C0005,
	0x1820, 0x00C10840,
	0x1824, 0x002A0461,
	0x1828, 0x002A0461,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x40EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x00050022,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x00000515,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000008,
};


unsigned int pdRegs1080i60_rgb2hdmi[] = {
	0x1800, 0x02000D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x002C0005,
	0x1820, 0x00C10840,
	0x1824, 0x00150230,
	0x1828, 0x02480463,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x40EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x00050022,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x0000081C,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x0000000C,
};


unsigned int pdRegs1080i50_rgb2hdmi[] = {
	0x1800, 0x02000D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x002C0005,
	0x1820, 0x00C10840,
	0x1824, 0x00150230,
	0x1828, 0x02480463,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x40EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x00050022,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x0000017B,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000000,
};

unsigned int pdRegs720p3d60_rgb2hdmi[] = {
	0x1800, 0x02000D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x00280005,
	0x1820, 0x01050604,
	0x1824, 0x001A05D7,
	0x1828, 0x001A02E9,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x40EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x0001002C,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x000007F7,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000008,
};


unsigned int pdRegs1080i3d60_rgb2hdmi[] = {
	0x1800, 0x02000D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x002C0005,
	0x1820, 0x00C10840,
	0x1824, 0x001508C8,
	0x1828, 0x02480463,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x40EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x0001002C,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x00000DEC,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x0000000C,
};

unsigned int pdRegs1080p3d24_rgb2hdmi[] = {
	0x1800, 0x02000D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x002C0005,
	0x1820, 0x00C10840,
	0x1824, 0x002a08C6,
	0x1828, 0x002a0461,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x40EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x0001002b,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x00000cf6,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000008,
};

unsigned int pdRegs2160p30_rgb2hdmi[] = {
	0x1800, 0x02000D4D,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x0058000a,
	0x1820, 0x01811080,
	0x1824, 0x205308c2,
	0x1828, 0x005308c2,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x40EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x00050023,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x00000515,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000008,
};


unsigned int pdRegs2160p50_rgb2hdmi[] = {
	0x1800, 0x02000D49,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x0058000a,
	0x1820, 0x01811080,
	0x1824, 0x205308c2,
	0x1828, 0x005308c2,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x40EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x00050023,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x00000515,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000008,
};


unsigned int pdRegs2160p60_rgb2hdmi[] = {
	0x1800, 0x00000D4d,
	0x1804, 0x20000000,
	0x1808, 0x60004000,
	0x180c, 0xA0008000,
	0x1810, 0xE000C000,
	0x1814, 0x80808080,
	0x1818, 0x80808080,
	0x181c, 0x0058000a,
	0x1820, 0x01811080,
	0x1824, 0x205308c2,
	0x1828, 0x005308c2,
	0x182c, 0x00000000,
	0x1830, 0x00000000,
	0x1834, 0x00000000,
	0x1838, 0x80010000,
	0x183c, 0x00000000,
	0x1840, 0x00111000,
	0x1844, 0x00000000,
	0x1848, 0x00000000,
	0x184c, 0x00000000,
	0x1850, 0xFEFF0100,
	0x1854, 0xEB001000,
	0x1858, 0x00000000,
	0x185c, 0x00000000,
	0x1860, 0x00EB0100,
	0x1864, 0x40EB0100,
	0x1868, 0x00EB0100,
	0x186c, 0x00000000,
	0x1870, 0x00000000,
	0x1874, 0x00000000,
	0x1878, 0x00000000,
	0x187c, 0x00000000,
	0x1880, 0x00000000,
	0x1884, 0x00000000,
	0x1888, 0x00000000,
	0x188c, 0x00000000,
	0x1890, 0xEC3F8080,
	0x1894, 0xFC06F60F,
	0x1898, 0x7505BAC4,
	0x189c, 0x00000000,
	0x18a0, 0xF4006080,
	0x18a4, 0xFFCB07F7,
	0x18a8, 0x50973B34,
	0x18ac, 0x00000000,
	0x18b0, 0x06B4020D,
	0x18b4, 0x00050023,
	0x18b8, 0xD4006400,
	0x18bc, 0x00004100,
	0x18c0, 0x00000001,
	0x18c4, 0x00000000,
	0x18c8, 0x00000000,
	0x18cc, 0x00000000,
	0x18d0, 0x00000515,
	0x18d4, 0x00000008,
	0x18d8, 0x00000000,
	0x18dc, 0x00000000,
	0x18e0, 0x00000000,
	0x18e4, 0x00000000,
	0x18e8, 0x00000000,
	0x18ec, 0x00000000,
	0x18f0, 0x00000000,
	0x18f4, 0x00000000,
	0x18f8, 0x00000000,
	0x18fc, 0x00000008,
};

static unsigned int pdMpegInfoReg[] = {
	0x19c, 0x00000001,	/* version */
	0x1A0, 0x00000085,	/* type */
	0x1A4, 0x0000000a,	/* length */
	0x188, 0x000000dE,	/* check sum */
	0x188, 0x00000040,
	0x188, 0x00000050,
	0x188, 0x00000000,
	0x188, 0x00000002,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000
};

static unsigned int pdMpegInfoReg2[] = {
	0x19c, 0x00000001,	/* version */
	0x1A0, 0x00000085,	/* type */
	0x1A4, 0x0000000a,	/* length */
	0x188, 0x000000d4,	/* check sum */
	0x188, 0x00000041,
	0x188, 0x00000052,
	0x188, 0x00000003,
	0x188, 0x00000002,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000004
};


static unsigned int pdSpdInfoReg[] = {
	0x19c, 0x00000001,	/* version */
	0x1A0, 0x00000083,	/* type */
	0x1A4, 0x00000019,	/* length, 25 bytes */
	0x188, 0x000000d1,	/* check sum */
	0x188, 0x00000040,
	0x188, 0x00000050,
	0x188, 0x00000000,
	0x188, 0x00000002,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000
};

static unsigned int pdSpdInfoReg2[] = {
	0x19c, 0x00000001,	/* version */
	0x1A0, 0x00000083,	/* type */
	0x1A4, 0x00000019,	/* length, 25 bytes */
	0x188, 0x000000cf,	/* check sum */
	0x188, 0x00000040,
	0x188, 0x00000050,
	0x188, 0x00000000,
	0x188, 0x00000002,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000002
};



static unsigned int pdAudioInfoReg[] = {
	0x19c, 0x00000001,	/* version */
	0x1A0, 0x00000084,	/* type */
	0x1A4, 0x0000000a,	/* length */
	0x188, 0x0000006a,	/* check sum */
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000007,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000
};

static unsigned int pdAudioInfoReg2[] = {
	0x19c, 0x00000001,	/* version */
	0x1A0, 0x00000084,	/* type */
	0x1A4, 0x0000000a,	/* length */
	0x188, 0x00000055,	/* check sum */
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000007,
	0x188, 0x00000001,
	0x188, 0x00000002,
	0x188, 0x00000003,
	0x188, 0x00000004,
	0x188, 0x00000005,
	0x188, 0x00000006
};


static unsigned int pdVendorSpecInfoReg[] = {
	0x19c, 0x00000001,	/* version */
	0x1A0, 0x00000081,	/* type */
	0x1A4, 0x0000000a,	/* length */
	0x188, 0x000000E2,	/* check sum */
	0x188, 0x00000040,
	0x188, 0x00000050,
	0x188, 0x00000000,
	0x188, 0x00000002,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000
};

static unsigned int pdVendorSpecInfoReg2[] = {
	0x19c, 0x00000001,	/* version */
	0x1A0, 0x00000081,	/* type */
	0x1A4, 0x0000000a,	/* length */
	0x188, 0x000000d2,	/* check sum */
	0x188, 0x00000040,
	0x188, 0x00000050,
	0x188, 0x00000000,
	0x188, 0x00000002,
	0x188, 0x00000001,
	0x188, 0x00000002,
	0x188, 0x00000003,
	0x188, 0x00000004,
	0x188, 0x00000006,
	0x188, 0x00000000
};


static unsigned int pdGenericInfoReg[] = {
	0x19c, 0x00000001,	/* version */
	0x1A0, 0x00000087,	/* type */
	0x1A4, 0x0000000a,	/* length */
	0x188, 0x000000DC,	/* check sum */
	0x188, 0x00000040,
	0x188, 0x00000050,
	0x188, 0x00000000,
	0x188, 0x00000002,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000,
	0x188, 0x00000000
};

static unsigned int pdGenericInfoReg2[] = {
	0x19c, 0x00000001,	/* version */
	0x1A0, 0x00000087,	/* type */
	0x1A4, 0x0000000a,	/* length */
	0x188, 0x000000BA,	/* check sum */
	0x188, 0x00000041,
	0x188, 0x00000051,
	0x188, 0x00000000,
	0x188, 0x00000002,
	0x188, 0x00000010,
	0x188, 0x00000001,
	0x188, 0x00000002,
	0x188, 0x00000003,
	0x188, 0x00000004,
	0x188, 0x00000006
};


unsigned int pdACPInfoReg[] = {
	0x19c, 0x00000002,	/* version, acp type */
	0x1A0, 0x00000004,	/* type */
	0x1A4, 0x00000000,	/* length */
	0x188, 0x000000dE,	/* check sum, PB0 */
	0x188, 0x00000040,
	0x188, 0x00000050,
	0x188, 0x00000000,
	0x188, 0x00000002
};

unsigned int pdACPInfoReg2[] = {
	0x19c, 0x00000002,	/* version, acp type */
	0x1A0, 0x00000004,	/* type */
	0x1A4, 0x00000000,	/* length */
	0x188, 0x000000dE,	/* check sum, PB0 */
	0x188, 0x00000040,
	0x188, 0x00000050,
	0x188, 0x00000001,
	0x188, 0x00000001
};


unsigned int pdISRC1InfoReg[] = {
	0x19c, 0x00000002,	/* version, ISRC status */
	0x1A0, 0x00000005,	/* type */
	0x1A4, 0x00000000,	/* length */
	0x188, 0x000000dE,	/* check sum, PB0 */
	0x188, 0x00000040,
	0x188, 0x00000050,
	0x188, 0x00000000,
	0x188, 0x00000002
};

unsigned int pdISRC1InfoReg2[] = {
	0x19c, 0x00000002,	/* version, ISRC status */
	0x1A0, 0x00000005,	/* type */
	0x1A4, 0x00000000,	/* length */
	0x188, 0x000000d0,	/* check sum, PB0 */
	0x188, 0x00000041,
	0x188, 0x00000051,
	0x188, 0x00000003,
	0x188, 0x00000001
};


unsigned int pdISRC2InfoReg[] = {
	0x19c, 0x00000000,	/* version, ISRC status */
	0x1A0, 0x00000006,	/* type */
	0x1A4, 0x00000000,	/* length */
	0x188, 0x000000dE,	/* check sum, PB0 */
	0x188, 0x00000040,
	0x188, 0x00000050,
	0x188, 0x00000000,
	0x188, 0x00000002
};

unsigned int pdISRC2InfoReg2[] = {
	0x19c, 0x00000000,	/* version, ISRC status */
	0x1A0, 0x00000006,	/* type */
	0x1A4, 0x00000000,	/* length */
	0x188, 0x000000d6,	/* check sum, PB0 */
	0x188, 0x00000042,
	0x188, 0x00000052,
	0x188, 0x00000002,
	0x188, 0x00000004
};


static unsigned int pdGamutInfoReg[] = {
	0x19c, 0x00000080,	/* HB1 version */
	0x1A0, 0x0000000a,	/* HB0 type */
	0x1A4, 0x00000030,	/* HB2 */
	0x188, 0x00000000	/* PB0 */
};

static unsigned int pdGamutInfoReg2[] = {
	0x19c, 0x00000080,	/* HB1 version */
	0x1A0, 0x0000000a,	/* HB0 type */
	0x1A4, 0x00000030,	/* HB2 */
	0x188, 0x00000001	/* PB0 */
};

static char debug_buffer[4095] = {0};
static unsigned int temp_len, buf_offset;

#define HDMI_ATTR_SPRINTF(fmt, arg...)  \
do { \
	TX_DEF_LOG(fmt, ##arg); \
	if (buf_offset < (sizeof(debug_buffer) - 1)) { \
		temp_len = \
		snprintf(debug_buffer + buf_offset, \
			sizeof(debug_buffer) - buf_offset, fmt, ##arg); \
		if (temp_len > 0) \
			buf_offset += temp_len; \
		debug_buffer[buf_offset] = 0; \
	} \
} while (0)

void mt_hdmi_show_edid_info(void)
{
	unsigned int u4Res = 0;
	unsigned char bInx = 0;

	HDMI_ATTR_SPRINTF(">>>>> HDMI Edid Information >>>>>>>\n");

	HDMI_ATTR_SPRINTF("[HDMI]EDID ver:%d/rev:%d\n",
		_HdmiSinkAvCap.ui1_Edid_Version,
		      _HdmiSinkAvCap.ui1_Edid_Revision);
	HDMI_ATTR_SPRINTF("[HDMI]EDID Extend Rev:%d\n",
		_HdmiSinkAvCap.ui1_ExtEdid_Revision);
	if (_HdmiSinkAvCap.b_sink_support_hdmi_mode)
		HDMI_ATTR_SPRINTF("[HDMI]SINK Device is HDMI\n");
	else
		HDMI_ATTR_SPRINTF("[HDMI]SINK Device is DVI\n");

	if (_HdmiSinkAvCap.b_sink_support_hdmi_mode)
		HDMI_ATTR_SPRINTF("[HDMI]CEC ADDRESS:%x\n",
		_HdmiSinkAvCap.ui2_sink_cec_address);

	HDMI_ATTR_SPRINTF("[HDMI]max clock limit : %d\n",
		_HdmiSinkAvCap.ui1_sink_max_tmds_clock);

	u4Res = (_HdmiSinkAvCap.ui4_sink_cea_ntsc_resolution |
		 _HdmiSinkAvCap.ui4_sink_dtd_ntsc_resolution |
		 _HdmiSinkAvCap.ui4_sink_cea_pal_resolution |
		 _HdmiSinkAvCap.ui4_sink_dtd_pal_resolution);

	if (u4Res & SINK_480I)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1440x480I 59.94hz\n");
	if (u4Res & SINK_480I_1440)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 2880x480I 59.94hz\n");
	if (u4Res & SINK_480P)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 720x480P 59.94hz\n");
	if (u4Res & SINK_480P_1440)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1440x480P 59.94hz\n");
	if (u4Res & SINK_480P_2880)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 2880x480P 59.94hz\n");
	if (u4Res & SINK_720P60)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1280x720P 59.94hz\n");
	if (u4Res & SINK_1080I60)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1920x1080I 59.94hz\n");
	if (u4Res & SINK_1080P60)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1920x1080P 59.94hz\n");

	if (u4Res & SINK_576I)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1440x576I 50hz\n");
	if (u4Res & SINK_576I_1440)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 2880x576I 50hz\n");
	if (u4Res & SINK_576P)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 720x576P 50hz\n");
	if (u4Res & SINK_576P_1440)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1440x576P 50hz\n");
	if (u4Res & SINK_576P_2880)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 2880x576P 50hz\n");
	if (u4Res & SINK_720P50)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1280x720P 50hz\n");
	if (u4Res & SINK_1080I50)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1920x1080I 50hz\n");
	if (u4Res & SINK_1080P50)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1920x1080P 50hz\n");
	if (u4Res & SINK_1080P30)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1920x1080P 30hz\n");
	if (u4Res & SINK_1080P24)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1920x1080P 24hz\n");
	if (u4Res & SINK_1080P25)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT 1920x1080P 25hz\n");

	u4Res =
	    (_HdmiSinkAvCap.ui4_sink_native_ntsc_resolution |
	    _HdmiSinkAvCap.ui4_sink_native_pal_resolution);
	HDMI_ATTR_SPRINTF("[HDMI]NTSC Native =%x\n",
		_HdmiSinkAvCap.ui4_sink_native_ntsc_resolution);
	HDMI_ATTR_SPRINTF("[HDMI]PAL Native =%x\n",
		_HdmiSinkAvCap.ui4_sink_native_pal_resolution);
	if (u4Res & SINK_480I)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1440x480I 59.94hz\n");
	if (u4Res & SINK_480I_1440)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 2880x480I 59.94hz\n");
	if (u4Res & SINK_480P)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 720x480P 59.94hz\n");
	if (u4Res & SINK_480P_1440)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1440x480P 59.94hz\n");
	if (u4Res & SINK_480P_2880)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 2880x480P 59.94hz\n");
	if (u4Res & SINK_720P60)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1280x720P 59.94hz\n");
	if (u4Res & SINK_1080I60)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1920x1080I 59.94hz\n");
	if (u4Res & SINK_1080P60)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1920x1080P 59.94hz\n");
	if (u4Res & SINK_576I)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1440x576I 50hz\n");
	if (u4Res & SINK_576I_1440)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 2880x576I 50hz\n");
	if (u4Res & SINK_576P)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 720x576P 50hz\n");
	if (u4Res & SINK_576P_1440)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1440x576P 50hz\n");
	if (u4Res & SINK_576P_2880)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 2880x576P 50hz\n");
	if (u4Res & SINK_720P50)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1280x720P 50hz\n");
	if (u4Res & SINK_1080I50)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1920x1080I 50hz\n");
	if (u4Res & SINK_1080P50)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1920x1080P 50hz\n");
	if (u4Res & SINK_1080P30)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1920x1080P 30hz\n");
	if (u4Res & SINK_1080P24)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1920x1080P 24hz\n");
	if (u4Res & SINK_1080P25)
		HDMI_ATTR_SPRINTF(
		"[HDMI]Native resolution is 1920x1080P 25hz\n");

	u4Res = _HdmiSinkAvCap.ui4_sink_hdmi_4k2kvic |
		_HdmiSinkAvCap.ui4_sink_hdmi_4k2kvic_420_vdb;
	if (u4Res & SINK_2160P_23_976HZ)
		HDMI_ATTR_SPRINTF(
		"[HDMI]4k2k support to SINK_2160P_23_976HZ\n");
	if (u4Res & SINK_2160P_24HZ)
		HDMI_ATTR_SPRINTF("[HDMI]4k2k support to SINK_2160P_24HZ\n");
	if (u4Res & SINK_2160P_25HZ)
		HDMI_ATTR_SPRINTF("[HDMI]4k2k support to SINK_2160P_25HZ\n");
	if (u4Res & SINK_2160P_29_97HZ)
		HDMI_ATTR_SPRINTF("[HDMI]4k2k support to SINK_2160P_29_97HZ\n");
	if (u4Res & SINK_2160P_30HZ)
		HDMI_ATTR_SPRINTF("[HDMI]4k2k support to SINK_2160P_30HZ\n");
	if (u4Res & SINK_2161P_24HZ)
		HDMI_ATTR_SPRINTF("[HDMI]4k2k support to SINK_2161P_24HZ\n");
	if (u4Res & SINK_2160P_50HZ)
		HDMI_ATTR_SPRINTF("[HDMI]4k2k support to SINK_2160P_50HZ\n");
	if (u4Res & SINK_2160P_60HZ)
		HDMI_ATTR_SPRINTF("[HDMI]4k2k support to SINK_2160P_60HZ\n");
	if (u4Res & SINK_2161P_50HZ)
		HDMI_ATTR_SPRINTF("[HDMI]4k2k support to SINK_2161P_50HZ\n");
	if (u4Res & SINK_2161P_60HZ)
		HDMI_ATTR_SPRINTF("[HDMI]4k2k support to SINK_2161P_60HZ\n");


	HDMI_ATTR_SPRINTF("[HDMI]SUPPORT RGB\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_YCBCR_444)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT YCBCR 444\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_YCBCR_422)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT YCBCR 422\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_YCBCR_420)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT YCBCR ONLY 420, 0x%x\n",
			      _HdmiSinkAvCap.ui4_sink_hdmi_4k2kvic_420_vdb);
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_YCBCR_420_CAPABILITY)
		HDMI_ATTR_SPRINTF(
	"[HDMI]SUPPORT YCBCR 420 and other colorspace, 0x%x\n",
			      _HdmiSinkAvCap.ui4_sink_hdmi_4k2kvic_420_vdb);
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_XV_YCC709)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT xvYCC 709\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_XV_YCC601)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT xvYCC 601\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_S_YCC601)
		HDMI_ATTR_SPRINTF("[HDMI]SINK_S_YCC601\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_ADOBE_YCC601)
		HDMI_ATTR_SPRINTF("[HDMI]SINK_ADOBE_YCC601\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_ADOBE_RGB)
		HDMI_ATTR_SPRINTF("[HDMI]SINK_ADOBE_RGB\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_COLOR_SPACE_BT2020_CYCC)
		HDMI_ATTR_SPRINTF("[HDMI]SINK_COLOR_SPACE_BT2020_CYCC\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_COLOR_SPACE_BT2020_YCC)
		HDMI_ATTR_SPRINTF("[HDMI]SINK_COLOR_SPACE_BT2020_YCC\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_COLOR_SPACE_BT2020_RGB)
		HDMI_ATTR_SPRINTF("[HDMI]SINK_COLOR_SPACE_BT2020_RGB\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_METADATA0)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT metadata P0\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_METADATA1)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT metadata P1\n");
	if (_HdmiSinkAvCap.ui2_sink_colorimetry & SINK_METADATA2)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT metadata P2\n");


	if (_HdmiSinkAvCap.e_sink_ycbcr_color_bit & HDMI_SINK_DEEP_COLOR_10_BIT)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT YCBCR 30 Bits Deep Color\n");
	if (_HdmiSinkAvCap.e_sink_ycbcr_color_bit & HDMI_SINK_DEEP_COLOR_12_BIT)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT YCBCR 36 Bits Deep Color\n");
	if (_HdmiSinkAvCap.e_sink_ycbcr_color_bit & HDMI_SINK_DEEP_COLOR_16_BIT)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT YCBCR 48 Bits Deep Color\n");
	if (_HdmiSinkAvCap.e_sink_ycbcr_color_bit == HDMI_SINK_NO_DEEP_COLOR)
		HDMI_ATTR_SPRINTF("[HDMI]Not SUPPORT YCBCR Deep Color\n");

	if (_HdmiSinkAvCap.ui1_sink_dc420_color_bit &
		HDMI_SINK_DEEP_COLOR_16_BIT)
		HDMI_ATTR_SPRINTF(
		"[HDMI]SUPPORT YCBCR420 48 Bits Deep Color\n");
	if (_HdmiSinkAvCap.ui1_sink_dc420_color_bit &
		HDMI_SINK_DEEP_COLOR_12_BIT)
		HDMI_ATTR_SPRINTF(
		"[HDMI]SUPPORT YCBCR420 36 Bits Deep Color\n");
	if (_HdmiSinkAvCap.ui1_sink_dc420_color_bit &
		HDMI_SINK_DEEP_COLOR_10_BIT)
		HDMI_ATTR_SPRINTF(
		"[HDMI]SUPPORT YCBCR420 30 Bits Deep Color\n");
	if (_HdmiSinkAvCap.ui1_sink_dc420_color_bit == HDMI_SINK_NO_DEEP_COLOR)
		HDMI_ATTR_SPRINTF("[HDMI]Not SUPPORT YCBCR420 Deep Color\n");

	if (_HdmiSinkAvCap.e_sink_rgb_color_bit & HDMI_SINK_DEEP_COLOR_10_BIT)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT RGB 30 Bits Deep Color\n");
	if (_HdmiSinkAvCap.e_sink_rgb_color_bit & HDMI_SINK_DEEP_COLOR_12_BIT)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT RGB 36 Bits Deep Color\n");
	if (_HdmiSinkAvCap.e_sink_rgb_color_bit & HDMI_SINK_DEEP_COLOR_16_BIT)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT RGB 48 Bits Deep Color\n");
	if (_HdmiSinkAvCap.e_sink_rgb_color_bit == HDMI_SINK_NO_DEEP_COLOR)
		HDMI_ATTR_SPRINTF("[HDMI]Not SUPPORT RGB Deep Color\n");

	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_LPCM)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT LPCM\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_AC3)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT AC3 Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_MPEG1)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT MPEG1 Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_MP3)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT AC3 Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_MPEG2)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT MPEG2 Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_AAC)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT AAC Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_DTS)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT DTS Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_ATRAC)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT ATRAC Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_DSD)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT SACD DSD Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_DOLBY_PLUS)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT Dolby Plus Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_DTS_HD)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT DTS HD Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_MAT_MLP)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT MAT MLP Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_DST)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT SACD DST Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_ATMOS)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT  ATMOS Decode\n");
	if (_HdmiSinkAvCap.ui2_sink_aud_dec & HDMI_SINK_AUDIO_DEC_WMA)
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT  WMA Decode\n");

	if (_HdmiSinkAvCap.ui1_sink_pcm_ch_sampling[0] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);


		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_pcm_ch_sampling[0] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT PCM Max 2CH, Fs is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_pcm_ch_sampling[4] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);

		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_pcm_ch_sampling[4] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT PCM Max 6CH, Fs is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_pcm_ch_sampling[5] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);

		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_pcm_ch_sampling[5] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT PCM Max 7CH, Fs is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_pcm_ch_sampling[6] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);

		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_pcm_ch_sampling[6] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT PCM Max 8CH, FS is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_ac3_ch_sampling[0] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);


		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_ac3_ch_sampling[0] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT AC3 Max 2CH, Fs is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_ac3_ch_sampling[4] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);

		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_ac3_ch_sampling[4] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT AC3 Max 6CH, Fs is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_ac3_ch_sampling[5] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);

		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_ac3_ch_sampling[5] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT AC3 Max 7CH, Fs is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_ac3_ch_sampling[6] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);

		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_ac3_ch_sampling[6] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT AC3 Max 8CH, FS is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_ec3_ch_sampling[0] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);


		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_ec3_ch_sampling[0] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT E-AC3 Max 2CH, Fs is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_ec3_ch_sampling[4] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);

		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_ec3_ch_sampling[4] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT E-AC3 Max 6CH, Fs is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_ec3_ch_sampling[5] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);

		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_ec3_ch_sampling[5] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT E-AC3 Max 7CH, Fs is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_ec3_ch_sampling[6] != 0) {

		for (bInx = 0; bInx < 50; bInx++)
			memcpy(&cDstStr[0 + bInx], " ", 1);

		for (bInx = 0; bInx < 7; bInx++) {
			if ((_HdmiSinkAvCap.ui1_sink_ec3_ch_sampling[6] >>
				bInx) & 0x01)
				memcpy(&cDstStr[0 + bInx * 7],
				&_cFsStr[bInx][0], 7);
		}
		HDMI_ATTR_SPRINTF("[HDMI]SUPPORT E-AC3 Max 8CH, FS is: %s\n",
			&cDstStr[0]);

	}

	if (_HdmiSinkAvCap.ui1_sink_spk_allocation & SINK_AUDIO_FL_FR)
		HDMI_ATTR_SPRINTF("[HDMI]Speaker FL/FR allocated\n");
	if (_HdmiSinkAvCap.ui1_sink_spk_allocation & SINK_AUDIO_LFE)
		HDMI_ATTR_SPRINTF("[HDMI]Speaker LFE allocated\n");
	if (_HdmiSinkAvCap.ui1_sink_spk_allocation & SINK_AUDIO_FC)
		HDMI_ATTR_SPRINTF("[HDMI]Speaker FC allocated\n");
	if (_HdmiSinkAvCap.ui1_sink_spk_allocation & SINK_AUDIO_RL_RR)
		HDMI_ATTR_SPRINTF("[HDMI]Speaker RL/RR allocated\n");
	if (_HdmiSinkAvCap.ui1_sink_spk_allocation & SINK_AUDIO_RC)
		HDMI_ATTR_SPRINTF("[HDMI]Speaker RC allocated\n");
	if (_HdmiSinkAvCap.ui1_sink_spk_allocation & SINK_AUDIO_FLC_FRC)
		HDMI_ATTR_SPRINTF("[HDMI]Speaker FLC/FRC allocated\n");
	if (_HdmiSinkAvCap.ui1_sink_spk_allocation & SINK_AUDIO_RLC_RRC)
		HDMI_ATTR_SPRINTF("[HDMI]Speaker RLC/RRC allocated\n");

	HDMI_ATTR_SPRINTF("[HDMI]HDMI edid support content type =%x\n",
		      _HdmiSinkAvCap.ui1_sink_content_cnc);
	HDMI_ATTR_SPRINTF("[HDMI]Lip Sync Progressive audio latency = %d\n",
		      _HdmiSinkAvCap.ui1_sink_p_audio_latency);
	HDMI_ATTR_SPRINTF("[HDMI]Lip Sync Progressive video latency = %d\n",
		      _HdmiSinkAvCap.ui1_sink_p_video_latency);
	if (_HdmiSinkAvCap.ui1_sink_i_latency_present) {
		HDMI_ATTR_SPRINTF(
			"[HDMI]Lip Sync Interlace audio latency = %d\n",
			      _HdmiSinkAvCap.ui1_sink_i_audio_latency);
		HDMI_ATTR_SPRINTF(
			"[HDMI]Lip Sync Interlace video latency = %d\n",
			      _HdmiSinkAvCap.ui1_sink_i_video_latency);
	}

	if (_HdmiSinkAvCap.ui1_sink_support_ai == 1)
		HDMI_ATTR_SPRINTF("[HDMI]Support AI\n");
	else
		HDMI_ATTR_SPRINTF("[HDMI]Not Support AI\n");

	HDMI_ATTR_SPRINTF("[HDMI]Monitor Max horizontal size = %d\n",
		      _HdmiSinkAvCap.ui1_Display_Horizontal_Size);
	HDMI_ATTR_SPRINTF("[HDMI]Monitor Max vertical size = %d\n",
		      _HdmiSinkAvCap.ui1_Display_Vertical_Size);


	if (_HdmiSinkAvCap.b_sink_hdmi_video_present == TRUE)
		HDMI_ATTR_SPRINTF("[HDMI]HDMI_Video_Present\n");
	else
		HDMI_ATTR_SPRINTF("[HDMI]No HDMI_Video_Present\n");

	if (_HdmiSinkAvCap.b_sink_3D_present == TRUE)
		HDMI_ATTR_SPRINTF("[HDMI]3D_present\n");
	else
		HDMI_ATTR_SPRINTF("[HDMI]No 3D_present\n");

	if (_HdmiSinkAvCap.b_sink_SCDC_present == TRUE)
		HDMI_ATTR_SPRINTF("[HDMI]HDMI_SCDC_Present\n");

	if (_HdmiSinkAvCap.b_sink_LTE_340M_sramble == TRUE)
		HDMI_ATTR_SPRINTF("[HDMI]LTE_340M_sramble\n");

	if (_HdmiSinkAvCap.ui1_sink_hf_vsdb_info &
		EDID_HF_VSDB_SCDC_PRESENT)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_HF_VSDB_SCDC_PRESENT EXIST\n");
	if (_HdmiSinkAvCap.ui1_sink_hf_vsdb_info &
		EDID_HF_VSDB_RR_CAPABLE)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_HF_VSDB_RR_CAPABLE EXIST\n");
	if (_HdmiSinkAvCap.ui1_sink_hf_vsdb_info &
		EDID_HF_VSDB_LTE_340MCSC_SCRAMBLE)
		HDMI_ATTR_SPRINTF(
		"[HDMI TX]EDID_HF_VSDB_LTE_340MCSC_SCRAMBLE EXIST\n");
	if (_HdmiSinkAvCap.ui1_sink_hf_vsdb_info &
		EDID_HF_VSDB_INDEPENDENT_VIEW)
		HDMI_ATTR_SPRINTF(
		"[HDMI TX]EDID_HF_VSDB_INDEPENDENT_VIEW EXIST\n");
	if (_HdmiSinkAvCap.ui1_sink_hf_vsdb_info &
		EDID_HF_VSDB_DUAL_VIEW)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_HF_VSDB_DUAL_VIEW EXIST\n");
	if (_HdmiSinkAvCap.ui1_sink_hf_vsdb_info &
		EDID_HF_VSDB_3D_OSD_DISPARITY)
		HDMI_ATTR_SPRINTF(
		"[HDMI TX]EDID_HF_VSDB_3D_OSD_DISPARITY EXIST\n");
	if (_HdmiSinkAvCap.ui1_sink_support_dynamic_hdr &
		EDID_SUPPORT_PHILIPS_HDR)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_SUPPORT_PHILIPS_HDR\n");
	if (_HdmiSinkAvCap.ui1_sink_support_dynamic_hdr &
		EDID_SUPPORT_DOLBY_HDR)
		HDMI_ATTR_SPRINTF(
	"[HDMI TX]EDID_SUPPORT_DOLBY_HDR(Dolby HDR Enable Bit)\n");
	if (_HdmiSinkAvCap.ui1_sink_support_dynamic_hdr &
		EDID_SUPPORT_YUV422_12BIT)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_SUPPORT_YUV422_12BIT\n");
	if (_HdmiSinkAvCap.ui1_sink_support_dynamic_hdr &
		EDID_SUPPORT_DOLBY_HDR_2160P60)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_SUPPORT_DOLBY_HDR_2160P60\n");
	if (_HdmiSinkAvCap.ui1_sink_support_dynamic_hdr &
		EDID_SUPPORT_HDR10_PLUS)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_SUPPORT_HDR10_PLUS\n");
	if (_HdmiSinkAvCap.ui1_sink_support_static_hdr &
		EDID_SUPPORT_SDR)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_SUPPORT_SDR\n");
	if (_HdmiSinkAvCap.ui1_sink_support_static_hdr &
		EDID_SUPPORT_HDR)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_SUPPORT_HDR\n");
	if (_HdmiSinkAvCap.ui1_sink_support_static_hdr &
		EDID_SUPPORT_SMPTE_ST_2084)
		HDMI_ATTR_SPRINTF(
	"[HDMI TX]EDID_SUPPORT_SMPTE_ST_2084(HDR10 Enable Bit)\n");
	if (_HdmiSinkAvCap.ui1_sink_support_static_hdr &
		EDID_SUPPORT_FUTURE_EOTF)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_SUPPORT_FUTURE_EOTF\n");
	if (_HdmiSinkAvCap.ui1_sink_support_static_hdr & EDID_SUPPORT_ET_4)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_SUPPORT_ET_4\n");
	if (_HdmiSinkAvCap.ui1_sink_support_static_hdr & EDID_SUPPORT_ET_5)
		HDMI_ATTR_SPRINTF("[HDMI TX]EDID_SUPPORT_ET_5\n");

	HDMI_ATTR_SPRINTF(
	"[HDMI TX]ui1_sink_hdr_content_max_luminance = 0x%x\n",
		_HdmiSinkAvCap.ui1_sink_hdr_content_max_luminance);
	HDMI_ATTR_SPRINTF(
	"[HDMI TX]ui1_sink_hdr_content_max_frame_average_luminance = 0x%x\n",
		_HdmiSinkAvCap
	.ui1_sink_hdr_content_max_frame_average_luminance);
	HDMI_ATTR_SPRINTF(
	"[HDMI TX]ui1_sink_hdr_content_min_luminance = 0x%x\n",
		_HdmiSinkAvCap.ui1_sink_hdr_content_min_luminance);

	HDMI_ATTR_SPRINTF(
	"[HDMI TX]HDR block=0x%x;0x%x;0x%x;0x%x;0x%x;0x%x;0x%x\n",
		_HdmiSinkAvCap.ui1_sink_hdr_block[0],
		_HdmiSinkAvCap.ui1_sink_hdr_block[1],
		_HdmiSinkAvCap.ui1_sink_hdr_block[2],
		_HdmiSinkAvCap.ui1_sink_hdr_block[3],
		_HdmiSinkAvCap.ui1_sink_hdr_block[4],
		_HdmiSinkAvCap.ui1_sink_hdr_block[5],
		_HdmiSinkAvCap.ui1_sink_hdr_block[6]);
	HDMI_ATTR_SPRINTF(
	"[HDMI TX]HFVSDB block=0x%x;0x%x;0x%x;0x%x;0x%x;0x%x;0x%x;0x%x\n",
		_HdmiSinkAvCap.ui1_sink_hfvsdb_block[0],
		_HdmiSinkAvCap.ui1_sink_hfvsdb_block[1],
		_HdmiSinkAvCap.ui1_sink_hfvsdb_block[2],
		_HdmiSinkAvCap.ui1_sink_hfvsdb_block[3],
		_HdmiSinkAvCap.ui1_sink_hfvsdb_block[4],
		_HdmiSinkAvCap.ui1_sink_hfvsdb_block[5],
		_HdmiSinkAvCap.ui1_sink_hfvsdb_block[6],
		_HdmiSinkAvCap.ui1_sink_hfvsdb_block[7]);

	HDMI_ATTR_SPRINTF("[HDMI TX]ui2_sink_max_tmds_character_rate = %d\n",
		_HdmiSinkAvCap.ui2_sink_max_tmds_character_rate);
	HDMI_ATTR_SPRINTF("[HDMI TX]ui1_sink_hf_vsdb_info = 0x%x\n",
		_HdmiSinkAvCap.ui1_sink_hf_vsdb_info);

}

void mt_hdmi_show_hdr_status(void)
{
	char str[30];
	enum VID_PLA_DR_TYPE_T ret;

	ret = hdr_status(str);
	HDMI_ATTR_SPRINTF("%s\n", str);
	HDMI_ATTR_SPRINTF("ret=%d\n", ret);
}

void hdmi_InfoframeSetting(unsigned char i1typemode,
	unsigned char i1typeselect)
{
	unsigned int u4Ind;

	if ((i1typemode == 0xff) && (i1typeselect == 0xff)) {
		HDMI_ATTR_SPRINTF("Arg1: Infoframe output type\n");
		HDMI_ATTR_SPRINTF("1: AVi, 2: Mpeg, 3: SPD\n");
		HDMI_ATTR_SPRINTF("4: Vendor, 5: Audio, 6: ACP\n");
		HDMI_ATTR_SPRINTF("7: ISRC1, 8: ISRC2,  9:GENERIC\n");
		HDMI_ATTR_SPRINTF("10:GAMUT\n");
		HDMI_ATTR_SPRINTF("Arg2: Infoframe data select\n");
		HDMI_ATTR_SPRINTF("0: old(default), 1: new;\n");
		return;
	}

	if (i1typeselect == 0) {
		switch (i1typemode) {
		case 1:	/* Avi */
			vSendAVIInfoFrame(HDMI_VIDEO_1280x720p_50Hz, 1);
			break;

		case 2:	/* Mpeg */
			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, MPEG_EN);
			for (u4Ind = 0; u4Ind <
				(sizeof(pdMpegInfoReg) / 4); u4Ind += 2)
				vWriteByteHdmiGRL(pdMpegInfoReg[u4Ind],
				pdMpegInfoReg[u4Ind + 1]);
			vWriteHdmiGRLMsk(TOP_INFO_EN, MPEG_EN, MPEG_EN);

			break;

		case 3:
			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, SPDIF_EN);
			for (u4Ind = 0; u4Ind < (sizeof(pdSpdInfoReg) /
				4); u4Ind += 2)
				vWriteByteHdmiGRL(pdSpdInfoReg[u4Ind],
				pdSpdInfoReg[u4Ind + 1]);
			vWriteHdmiGRLMsk(TOP_INFO_EN, SPDIF_EN, SPDIF_EN);
			break;


		case 4:
			/* Vendor spec */
			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, VSIF_EN);
			for (u4Ind = 0; u4Ind <
				(sizeof(pdVendorSpecInfoReg) / 4); u4Ind += 2)
				vWriteByteHdmiGRL(pdVendorSpecInfoReg[u4Ind],
				pdVendorSpecInfoReg[u4Ind + 1]);
			vWriteHdmiGRLMsk(TOP_INFO_EN, VSIF_EN, VSIF_EN);
			break;


		case 5:
			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, AUD_EN);
			for (u4Ind = 0; u4Ind <
				(sizeof(pdAudioInfoReg) / 4); u4Ind += 2)
				vWriteByteHdmiGRL(pdAudioInfoReg[u4Ind],
				pdAudioInfoReg[u4Ind + 1]);
			vWriteHdmiGRLMsk(TOP_INFO_EN, AUD_EN, AUD_EN);

			break;

		case 9:
			/* Generic spec */
			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, GEN_EN);
			for (u4Ind = 0; u4Ind <
				(sizeof(pdGenericInfoReg) / 4); u4Ind += 2)
				vWriteByteHdmiGRL(pdGenericInfoReg[u4Ind],
						  pdGenericInfoReg[u4Ind + 1]);

			vWriteHdmiGRLMsk(TOP_INFO_EN, GEN_EN, GEN_EN);
			break;

		case 10:

			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, HDMI2_GAMUT_EN);
			for (u4Ind = 0; u4Ind <
				(sizeof(pdGamutInfoReg) / 4); u4Ind += 2)
				vWriteByteHdmiGRL(pdGamutInfoReg[u4Ind],
				pdGamutInfoReg[u4Ind + 1]);

			vWriteHdmiGRLMsk(TOP_INFO_EN, HDMI2_GAMUT_EN,
				HDMI2_GAMUT_EN);

			vSendAVIInfoFrame(HDMI_VIDEO_720x480p_60Hz,
				HDMI_XV_YCC);

			break;

		case 15:
			/* vCMDHwNCTSOnOff(FALSE);// change to software NCTS; */
			/* vCMDHDMI_NCTS(0x03, 0x12); */

			break;
		default:
			break;

		}
	} else {
		switch (i1typemode) {
		case 1:	/* Avi */

			vSendAVIInfoFrame(HDMI_VIDEO_1280x720p_50Hz, 2);

			break;

		case 2:	/* Mpeg */
			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, MPEG_EN);
			for (u4Ind = 0; u4Ind <
				(sizeof(pdMpegInfoReg2) / 4); u4Ind += 2)
				vWriteByteHdmiGRL(pdMpegInfoReg2[u4Ind],
				pdMpegInfoReg2[u4Ind + 1]);
			vWriteHdmiGRLMsk(TOP_INFO_EN, MPEG_EN, MPEG_EN);

			break;

		case 3:
			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, SPD_EN);
			for (u4Ind = 0; u4Ind <
				(sizeof(pdSpdInfoReg2) / 4); u4Ind += 2)
				vWriteByteHdmiGRL(pdSpdInfoReg2[u4Ind],
				pdSpdInfoReg2[u4Ind + 1]);
			vWriteHdmiGRLMsk(TOP_INFO_EN, SPD_EN, SPD_EN);
			break;


		case 4:
			/* Vendor spec */
			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, VSIF_EN);
			for (u4Ind = 0; u4Ind <
				(sizeof(pdVendorSpecInfoReg2) / 4); u4Ind += 2)
				vWriteByteHdmiGRL(pdVendorSpecInfoReg2[u4Ind],
				pdVendorSpecInfoReg2[u4Ind + 1]);
			vWriteHdmiGRLMsk(TOP_INFO_EN, VSIF_EN, VSIF_EN);
			break;


		case 5:
			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, AUD_EN);
			for (u4Ind = 0; u4Ind <
				(sizeof(pdAudioInfoReg2) / 4); u4Ind += 2)
				vWriteByteHdmiGRL(pdAudioInfoReg2[u4Ind],
						  pdAudioInfoReg2[u4Ind + 1]);
			vWriteHdmiGRLMsk(TOP_INFO_EN, AUD_EN, AUD_EN);

			break;

		case 9:
			/* Generic spec */

			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, GEN_EN);
			for (u4Ind = 0; u4Ind <
				(sizeof(pdGenericInfoReg2) / 4); u4Ind += 2)
				vWriteByteHdmiGRL(pdGenericInfoReg2[u4Ind],
						  pdGenericInfoReg2[u4Ind + 1]);

			vWriteHdmiGRLMsk(TOP_INFO_EN, GEN_EN, GEN_EN);
			break;

		case 10:

			vWriteHdmiGRLMsk(TOP_INFO_EN, 0, HDMI2_GAMUT_EN);
			for (u4Ind = 0; u4Ind < (sizeof(pdGamutInfoReg2) /
				4); u4Ind += 2)
				vWriteByteHdmiGRL(pdGamutInfoReg2[u4Ind],
						  pdGamutInfoReg2[u4Ind + 1]);
			vWriteHdmiGRLMsk(TOP_INFO_EN, HDMI2_GAMUT_EN,
				HDMI2_GAMUT_EN);

			vSendAVIInfoFrame(HDMI_VIDEO_720x480p_60Hz,
				HDMI_XV_YCC);

			break;

		case 15:
		/* vCMDHwNCTSOnOff(FALSE);// change to software NCTS; */
		/* vCMDHDMI_NCTS(0x03, 0x12); */

			break;
		default:
			break;

		}

	}
}

void hdmi_fmtsetting(unsigned int resolutionmode)
{
	unsigned int u4Ind;

	HDMI_DRV_FUNC();

	switch (resolutionmode) {
	case HDMI_VIDEO_720x480i_60Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegsP2I480) / 4); u4Ind += 2)
			vWriteP2I(pdRegsP2I480[u4Ind],
			pdRegsP2I480[u4Ind + 1]);

		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs480i_fmtsetting) / 4); u4Ind += 2)
			vWriteVdout10(pdRegs480i_fmtsetting[u4Ind],
			pdRegs480i_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_720x576i_50Hz:
		for (u4Ind = 0; u4Ind < (sizeof(pdRegsP2I576) /
			4); u4Ind += 2)
			vWriteP2I(pdRegsP2I576[u4Ind],
			pdRegsP2I576[u4Ind + 1]);

		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs576i_fmtsetting) / 4); u4Ind += 2)
			vWriteVdout10(pdRegs576i_fmtsetting[u4Ind],
			pdRegs576i_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_720x480p_60Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs480p_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs480p_fmtsetting[u4Ind],
			pdRegs480p_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_720x576p_50Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs576p_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs576p_fmtsetting[u4Ind],
			pdRegs576p_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_1280x720p_60Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs720p60_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs720p60_fmtsetting[u4Ind],
			pdRegs720p60_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_1280x720p_50Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs720p50_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs720p50_fmtsetting[u4Ind],
			pdRegs720p50_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_1920x1080i_60Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegsP2I1080I60) / 4); u4Ind += 2)
			vWriteP2I(pdRegsP2I1080I60[u4Ind],
			pdRegsP2I1080I60[u4Ind + 1]);
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs1080i60_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs1080i60_fmtsetting[u4Ind],
			pdRegs1080i60_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_1920x1080i_50Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegsP2I1080I50) / 4); u4Ind += 2)
			vWriteP2I(pdRegsP2I1080I50[u4Ind],
			pdRegsP2I1080I50[u4Ind + 1]);

		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs1080i50_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs1080i50_fmtsetting[u4Ind],
			pdRegs1080i50_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_1920x1080p_60Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs1080p60_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs1080p60_fmtsetting[u4Ind],
			pdRegs1080p60_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_1920x1080p_50Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs1080p50_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs1080p50_fmtsetting[u4Ind],
			pdRegs1080p50_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_1280x720p3d_60Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs720p3d60_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs720p3d60_fmtsetting[u4Ind],
			pdRegs720p3d60_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_1920x1080i3d_60Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs1080i3d60_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs1080i3d60_fmtsetting[u4Ind],
			pdRegs1080i3d60_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_1920x1080p3d_24Hz:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs1080p3d24_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs1080p3d24_fmtsetting[u4Ind],
				    pdRegs1080p3d24_fmtsetting[u4Ind + 1]);
		break;

	case HDMI_VIDEO_3840x2160P_30HZ:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs2160p30_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs2160p30_fmtsetting[u4Ind],
			pdRegs2160p30_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_3840x2160P_50HZ:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs2160p50_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs2160p50_fmtsetting[u4Ind],
			pdRegs2160p50_fmtsetting[u4Ind + 1]);
		break;
	case HDMI_VIDEO_3840x2160P_60HZ:
		for (u4Ind = 0; u4Ind <
			(sizeof(pdRegs2160p60_fmtsetting) /
			4); u4Ind += 2)
			vWriteVdout10(pdRegs2160p60_fmtsetting[u4Ind],
			pdRegs2160p60_fmtsetting[u4Ind + 1]);
		break;

	default:

		break;

	}

}

void rgb2hdmi_setting(unsigned int resolutionmode)
{
	unsigned int u4Ind;

	HDMI_DRV_FUNC();
	temprgb2hdmi = 0;

	switch (resolutionmode) {
	case HDMI_VIDEO_720x480i_60Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs480i_rgb2hdmi[u4Ind],
				pdRegs480i_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs480i_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs480i_rgb2hdmi[u4Ind],
				pdRegs480i_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs480i_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs480i_rgb2hdmi[u4Ind],
				pdRegs480i_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_720x576i_50Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs576i_rgb2hdmi[u4Ind],
				pdRegs576i_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs576i_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs576i_rgb2hdmi[u4Ind],
				pdRegs576i_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs576i_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs576i_rgb2hdmi[u4Ind],
				pdRegs576i_rgb2hdmi[u4Ind + 1]);
		}
		break;

	case HDMI_VIDEO_720x480p_60Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 85; u4Ind += 2)
				vWriteRGB2HDMI(Regs480p_rgb2hdmi[u4Ind],
				Regs480p_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 86; u4Ind <
				(sizeof(Regs480p_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(Regs480p_rgb2hdmi[u4Ind],
				Regs480p_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(Regs480p_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(Regs480p_rgb2hdmi[u4Ind],
				Regs480p_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_720x576p_50Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs576p_rgb2hdmi[u4Ind],
				pdRegs576p_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs576p_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs576p_rgb2hdmi[u4Ind],
				pdRegs576p_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs576p_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs576p_rgb2hdmi[u4Ind],
				pdRegs576p_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_1280x720p_60Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs720p60_rgb2hdmi[u4Ind],
				pdRegs720p60_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs720p60_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs720p60_rgb2hdmi[u4Ind],
				pdRegs720p60_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs720p60_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs720p60_rgb2hdmi[u4Ind],
				pdRegs720p60_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_1280x720p_50Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs720p50_rgb2hdmi[u4Ind],
				pdRegs720p50_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs720p50_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs720p50_rgb2hdmi[u4Ind],
				pdRegs720p50_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs720p50_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs720p50_rgb2hdmi[u4Ind],
				pdRegs720p50_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_1920x1080i_60Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080i60_rgb2hdmi[u4Ind],
				pdRegs1080i60_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs1080i60_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080i60_rgb2hdmi[u4Ind],
				pdRegs1080i60_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs1080i60_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080i60_rgb2hdmi[u4Ind],
				pdRegs1080i60_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_1920x1080i_50Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080i50_rgb2hdmi[u4Ind],
				pdRegs1080i50_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs1080i50_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080i50_rgb2hdmi[u4Ind],
				pdRegs1080i50_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs1080i50_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080i50_rgb2hdmi[u4Ind],
				pdRegs1080i50_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_1920x1080p_60Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 85; u4Ind += 2)
				vWriteRGB2HDMI(Regs1080p60_rgb2hdmi[u4Ind],
				Regs1080p60_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 86; u4Ind <
				(sizeof(Regs1080p60_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(Regs1080p60_rgb2hdmi[u4Ind],
				Regs1080p60_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(Regs1080p60_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(Regs1080p60_rgb2hdmi[u4Ind],
				Regs1080p60_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_1920x1080p_50Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(Regs1080p50_rgb2hdmi[u4Ind],
				Regs1080p50_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(Regs1080p50_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(Regs1080p50_rgb2hdmi[u4Ind],
				Regs1080p50_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(Regs1080p50_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(Regs1080p50_rgb2hdmi[u4Ind],
				Regs1080p50_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_1280x720p3d_60Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs720p3d60_rgb2hdmi[u4Ind],
				pdRegs720p3d60_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs720p3d60_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs720p3d60_rgb2hdmi[u4Ind],
				pdRegs720p3d60_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs720p3d60_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs720p3d60_rgb2hdmi[u4Ind],
				pdRegs720p3d60_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_1920x1080i3d_60Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080i3d60_rgb2hdmi[u4Ind],
				pdRegs1080i3d60_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs1080i3d60_rgb2hdmi) / 4);
			     u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080i3d60_rgb2hdmi[u4Ind],
				pdRegs1080i3d60_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs1080i3d60_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080i3d60_rgb2hdmi[u4Ind],
				pdRegs1080i3d60_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_1920x1080p3d_24Hz:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080p3d24_rgb2hdmi[u4Ind],
				pdRegs1080p3d24_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs1080p3d24_rgb2hdmi) / 4);
			     u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080p3d24_rgb2hdmi[u4Ind],
				pdRegs1080p3d24_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs1080p3d24_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs1080p3d24_rgb2hdmi[u4Ind],
				pdRegs1080p3d24_rgb2hdmi[u4Ind + 1]);
		}
		break;

	case HDMI_VIDEO_3840x2160P_30HZ:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs2160p30_rgb2hdmi[u4Ind],
					    pdRegs2160p30_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs2160p30_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs2160p30_rgb2hdmi[u4Ind],
					    pdRegs2160p30_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs2160p30_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs2160p30_rgb2hdmi[u4Ind],
					    pdRegs2160p30_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_3840x2160P_50HZ:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs2160p50_rgb2hdmi[u4Ind],
					    pdRegs2160p50_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs2160p50_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs2160p50_rgb2hdmi[u4Ind],
					    pdRegs2160p50_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs2160p50_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs2160p50_rgb2hdmi[u4Ind],
					    pdRegs2160p50_rgb2hdmi[u4Ind + 1]);
		}
		break;
	case HDMI_VIDEO_3840x2160P_60HZ:
		if (temprgb2hdmi == 1) {
			for (u4Ind = 0; u4Ind < 127; u4Ind += 2)
				vWriteRGB2HDMI(pdRegs2160p60_rgb2hdmi[u4Ind],
					    pdRegs2160p60_rgb2hdmi[u4Ind + 1]);
		} else if (temprgb2hdmi == 2) {
			for (u4Ind = 128; u4Ind <
				(sizeof(pdRegs2160p60_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs2160p60_rgb2hdmi[u4Ind],
					    pdRegs2160p60_rgb2hdmi[u4Ind + 1]);
		} else {
			for (u4Ind = 0; u4Ind <
				(sizeof(pdRegs2160p60_rgb2hdmi) /
				4); u4Ind += 2)
				vWriteRGB2HDMI(pdRegs2160p60_rgb2hdmi[u4Ind],
					    pdRegs2160p60_rgb2hdmi[u4Ind + 1]);
		}
		break;
	default:

		break;

	}

	temprgb2hdmi = 1;
}

void vSetRptMode(unsigned int mode)
{
	unsigned int hdmi_mode = mode;

	vWriteIoHdmiAnaMsk(HDMI_CTL_3,
		(1 << reg_osdtvd_rx_dpclr_sel_SHIFT),
		reg_osdtvd_rx_dpclr_sel);

	if (hdmi_mode == 0) {
		vWriteHdmiGRLMsk(HDMITX_CONFIG, 0, HDMITX_MUX);
		vWriteHdmiGRLMsk(HDMI_BYPS_CFG, 0, rg_full_byps_mode);
	} else if (hdmi_mode == 1) { //rpt tmds mode
		vWriteHdmiGRLMsk(HDMI_BYPS_CFG,
			rg_full_byps_mode, rg_full_byps_mode);
	} else if (hdmi_mode == 2) { //rpt pixel mode
		vWriteHdmiGRLMsk(HDMITX_CONFIG, HDMITX_MUX, HDMITX_MUX);
		vWriteHdmiGRLMsk(HDMI_BYPS_CFG,
			0, rg_full_byps_mode);
	}

	vWriteByteHdmiGRL(HDCP_TOP_CTRL, 0x0);
}

static unsigned int SetHDMITXPLL(char *str_p)
{
	unsigned int resolutionmode;
	unsigned int deepcolor;
	unsigned int rptmode;
	unsigned int clkrate;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("res/deepcolor:0xPPP/0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x/0x%x/0x%x/%d", &resolutionmode, &deepcolor,
		&rptmode, &clkrate);
	if (ret != 4)
		return 0;

	HDMI_ATTR_SPRINTF("resolutionmode=%d,deepcolor=%d,rptmode=%d\n",
		resolutionmode, deepcolor, rptmode);
	vTxSignalOnOff(SV_OFF);
	vSetHDMITxPLL(resolutionmode, deepcolor, rptmode, clkrate);
	vTmdsPresetOn();
	vTxSignalOnOff(SV_ON);
	HDMI_ATTR_SPRINTF("RES chg Command OK\n");
	return 0;
}

void hdmitx_configsetting(unsigned int resolutionmode)
{
	vWriteIoHdmiAnaMsk(HDMI_ANA_CTL, reg_ana_hdmi20_fifo_en,
		reg_ana_hdmi20_fifo_en);
	/* output from analog20 port */

	if (((resolutionmode == HDMI_VIDEO_3840x2160P_50HZ)
	     || (resolutionmode == HDMI_VIDEO_3840x2160P_60HZ))
	    && !(_stAvdAVInfo.e_video_color_space == HDMI_YCBCR_420)) {
		HDMI_ATTR_SPRINTF("%s Over 3G\n", __func__);
		vWriteIoHdmiAnaMsk(HDMI20_CLK_CFG,
			(0x2 << reg_txc_div_SHIFT), reg_txc_div);
	} else {
		HDMI_ATTR_SPRINTF("%s Under 3G\n", __func__);
		vWriteIoHdmiAnaMsk(HDMI20_CLK_CFG, 0, reg_txc_div);
	}
}

static unsigned int _SetColorHw(int ucColorSpace)
{
	if (ucColorSpace == 1) {	/* RGB */
		vWriteRGB2HDMIMsk(HDMI_RGB_CTRL, (1 << 2),
			(1 << 2) | (1 << 16));
		if (_u4VideoRes == HDMI_VIDEO_720x480i_60Hz)
			vWriteRGB2HDMIMsk(HDMI_RGB_CTRL, (1 << 20),
			(1 << 20) | (0x0f << 12));
		else if (_u4VideoRes == HDMI_VIDEO_720x576i_50Hz)
			vWriteRGB2HDMIMsk(HDMI_RGB_CTRL, (1 << 20),
			(1 << 20) | (0x0f << 12));
	} else if (ucColorSpace == 2) {	/* YUV444 */
		vWriteRGB2HDMIMsk(HDMI_RGB_CTRL, 0, (1 << 2) |
			(1 << 16));
		if (_u4VideoRes == HDMI_VIDEO_720x480i_60Hz)
			vWriteRGB2HDMIMsk(HDMI_RGB_CTRL, (1 << 20),
			(1 << 20) | (0x0f << 12));
		else if (_u4VideoRes == HDMI_VIDEO_720x576i_50Hz)
			vWriteRGB2HDMIMsk(HDMI_RGB_CTRL, (1 << 20),
			(1 << 20) | (0x0f << 12));
	} else if (ucColorSpace == 3) {	/* YUV 4:2:2 */
		vWriteRGB2HDMIMsk(HDMI_RGB_CTRL, (1 << 16), (1 << 2) |
			(1 << 16));

		if (_u4VideoRes == HDMI_VIDEO_720x480i_60Hz)
			vWriteRGB2HDMIMsk(HDMI_RGB_CTRL, (1 << 20) | (1 << 21),
				       (1 << 21) | (1 << 20) | (0x0f << 12));
		else if (_u4VideoRes == HDMI_VIDEO_720x576i_50Hz)
			vWriteRGB2HDMIMsk(HDMI_RGB_CTRL, (1 << 20) | (1 << 21),
				       (1 << 21) | (1 << 20) | (0x0f << 12));
	}

	if ((_u4VideoRes >= HDMI_VIDEO_1280x720p_60Hz) &&
		(_u4VideoRes <= HDMI_VIDEO_RESOLUTION_NUM))	/* HD */
		vWriteRGB2HDMIMsk(HDMI_RGB2HDMI_64, 0x04, (7 << 28));
	else
		vWriteRGB2HDMIMsk(HDMI_RGB2HDMI_64, 0, (7 << 28));
	_u4ColorSpace = ucColorSpace;
	return 0;
}

void set_hdmi_tmds_driver(unsigned int resolutionmode,
			  unsigned int deepcolor,
			  unsigned int colorspace,
			  unsigned int audiofs,
			  unsigned int chnumber,
			  unsigned int audiotype, unsigned int hdcponoff,
			  unsigned int setfmt)
{
	unsigned int bData;

	memset(&_stAvdAVInfo, 0, sizeof(struct HDMI_AV_INFO_T));
	_stAvdAVInfo.e_video_color_space = colorspace;
	_stAvdAVInfo.e_resolution = resolutionmode;
	_u4VideoRes = resolutionmode;

	force_plugin(colorspace);

	/*if (fgIsHDRes(resolutionmode)) */
	HDMI_ATTR_SPRINTF(
	"%s Res = 0x%x-------\n", __func__,
	resolutionmode);

	hdmitx_configsetting(resolutionmode);
	if (setfmt)
		hdmi_fmtsetting(resolutionmode);
	rgb2hdmi_setting(resolutionmode);
	vTxSignalOnOff(SV_OFF);
	vSetHDMITxPLL(resolutionmode, deepcolor, 0, 27000);

	vResetHDMI(0x1);
	HAL_Delay_us(1000);
	vResetHDMI(0x0);

	bData = bReadByteHdmiGRL(HDCP_TOP_CTRL);
	HDMI_ATTR_SPRINTF("[hdmi]HDCP_TOP_CTRL1 = 0x%x-------\n", bData);
	vWriteHdmiGRLMsk(HDCP_TOP_CTRL, OTPVMUTEOVR_UNSET, OTPVMUTEOVR_SET);
	vWriteHdmiGRLMsk(HDCP_TOP_CTRL, OTPADROPOVR_UNSET, OTPADROPOVR_SET);
	vWriteHdmiGRLMsk(HDCP_TOP_CTRL, OTPAMUTEOVR_UNSET, OTPAMUTEOVR_SET);
	vWriteHdmiGRLMsk(HDCP_TOP_CTRL, OTP2XVOVR_DIS |
		OTP2XAOVR_DIS, OTP2XVOVR_EN | OTP2XAOVR_EN);
	vWriteHdmiGRLMsk(HDCP_TOP_CTRL, OTP14VOVR_DIS |
		OTP14AOVR_DIS, OTP14VOVR_EN | OTP14AOVR_EN);
	bData = bReadByteHdmiGRL(HDCP_TOP_CTRL);
	HDMI_ATTR_SPRINTF("[HDMI]HDCP_TOP_CTRL2 = 0x%x-------\n", bData);

	vTmdsPresetOn();
	if ((resolutionmode == HDMI_VIDEO_3840x2160P_60HZ)
	    || (resolutionmode == HDMI_VIDEO_3840x2160P_50HZ)
	    || ((resolutionmode == HDMI_VIDEO_3840x2160P_30HZ)
		&& ((deepcolor == 2) || (deepcolor == 3) ||
		(deepcolor == 4)))) {
		HDMI_ATTR_SPRINTF("over 3G-------\n");
		vSendTMDSConfiguration(2);
		HAL_Delay_us(10);
	} else {
		vSendTMDSConfiguration(0);
		HAL_Delay_us(10);
	}
	vTxSignalOnOff(SV_ON);

	if (deepcolor == 1)
		vEnableDeepColor(FALSE, deepcolor);
	else
		vEnableDeepColor(TRUE, deepcolor);

	vEnableHdmiMode(1);
	if (colorspace == HDMI_YCBCR_420) {
		vWriteByteHdmiGRL(VID_DOWNSAMPLE_CONFIG, 0x00000351);
		vWriteByteHdmiGRL(VID_OUT_FORMAT, 0x00000400);
		vWriteRGB2HDMI(HDMI_RGB_CTRL, 0xd41);
		if (deepcolor == 1)
			vWriteIoHdmiAnaMsk(HDMI20_CLK_CFG, 0, reg_txc_div);

	}
	vSendAVIInfoFrame(resolutionmode, colorspace);
	vSendVendorSpecificInfoFrame(resolutionmode);
	vHDMIAVUnMute();

	if ((resolutionmode == HDMI_VIDEO_3840x2160P_60HZ)
	    || (resolutionmode == HDMI_VIDEO_3840x2160P_50HZ)
	    || ((resolutionmode == HDMI_VIDEO_3840x2160P_30HZ)
		&& ((deepcolor == 2) || (deepcolor == 3) ||
		(deepcolor == 4)))) {
		if ((colorspace == HDMI_YCBCR_420) && (deepcolor == 1)) {
			HDMI_ATTR_SPRINTF("4K 420 3G 1-------\n");
			vSendTMDSConfiguration(0);
			HAL_Delay_us(1000);
		} else {
			HDMI_ATTR_SPRINTF("over 3G 1-------\n");
			vSendTMDSConfiguration(3);
			HAL_Delay_us(2000);
			vWriteHdmiGRLMsk(TOP_CFG00, SCR_ON |
				HDMI2_ON, SCR_ON | HDMI2_ON);
		}
	} else {
		HDMI_ATTR_SPRINTF("under 3G 1-------\n");
		vSendTMDSConfiguration(0);
		HAL_Delay_us(1000);
	}
	_stAvdAVInfo.e_deep_color_bit = deepcolor;
	HDMI_ATTR_SPRINTF("e_deep_color_bit=%d-------\n",
		_stAvdAVInfo.e_deep_color_bit);

	v4k6G_set_clock();

	HDMI_ATTR_SPRINTF("end-------\n");
	_SetColorHw(colorspace);
}

static unsigned int set_hdmi_output_hdmi(char *str_p)
{
	unsigned int resolutionmode;
	unsigned int deepcolor;
	unsigned int colorspace;
	unsigned int hdcponoff;
	unsigned int setfmt = 0;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF(
		"sethdmi:0xPPP/0xPPP/0xPPP/0xPPP/0xPPP\n");
		return 0;
	}

	ret =
	    sscanf(str_p, "0x%x/0x%x/0x%x/0x%x/0x%x",
	    &resolutionmode, &deepcolor, &colorspace,
		   &hdcponoff, &debugonoff);
	if (ret != 5)
		return 0;

	HDMI_ATTR_SPRINTF(
"resolutionmode=%d,deepcolor=%d,colorspace=%d,hdcponoff=%d, setfmt=%d\n",
		      resolutionmode, deepcolor, colorspace, hdcponoff, setfmt);
	if (resolutionmode < HDMI_VIDEO_RESOLUTION_NUM &&
		deepcolor < HDMI_DEEP_COLOR_T_NUM &&
		colorspace < HDMI_OUT_COLOR_SPACE_T_NUM) {
		set_hdmi_tmds_driver(resolutionmode, deepcolor,
			colorspace, 0, 2, 0, hdcponoff, setfmt);
	} else {
		TX_DEF_LOG("RES chg out of range.\n");
		return FALSE;
	}
	HDMI_ATTR_SPRINTF("RES chg Command OK\n");
	return 0;
}

static unsigned int set_hdmi_video_config(char *str_p)
{
	unsigned int resolutionmode;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("fixvideo:0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x", &resolutionmode);
	if (ret != 1)
		return 0;

	if (resolutionmode < HDMI_VIDEO_RESOLUTION_NUM)
		force_video_config(resolutionmode);
	else
		TX_DEF_LOG("resolutionmode out of range.\n");
	return 0;
}

static unsigned int set_hdmi_audio_config(void)
{
	force_audio_config();
	return 0;
}

static unsigned int set_pmx_parameter(char *str_p)
{
	unsigned int resolutionmode;
	unsigned int temp;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("fixpmx:0xPPP/0xPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x/0x%x", &resolutionmode, &temp);
	if (ret != 2)
		return 0;

	if (resolutionmode < HDMI_VIDEO_RESOLUTION_NUM)
		pmx_parameter(resolutionmode, temp);
	else
		TX_DEF_LOG("resolutionmode out of range.\n");
	return 0;
}

static unsigned int hdmi_read_edid(char *str_p)
{
	unsigned int edidmode;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("readedid:0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x", &edidmode);
	if (ret != 1)
		return 0;

	hdmi_checkedid(edidmode);
	return 0;
}

static unsigned int hdmi_status(void)
{
	hdmi_hdmistatus();
	return 0;
}

static unsigned int set_colordeep(char *str_p)
{
	unsigned int colorspace;
	unsigned int deepcolor;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("codeep:0xPPP/0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x/0x%x", &colorspace,
		&deepcolor);
	if (ret != 2)
		return 0;

	HDMI_ATTR_SPRINTF("color = %d; deep = %d\n",
		colorspace, deepcolor);
	if (deepcolor < HDMI_DEEP_COLOR_T_NUM &&
		colorspace < HDMI_OUT_COLOR_SPACE_T_NUM) {
		_stAvdAVInfo.e_video_color_space = colorspace;
		_stAvdAVInfo.e_deep_color_bit = deepcolor;
	} else {
		TX_DEF_LOG("color or deep out of range.\n");
		return FALSE;
	}

	if (colorspace == HDMI_YCBCR_420)
		_HdmiSinkAvCap.ui2_sink_colorimetry = SINK_YCBCR_420;
	else
		_HdmiSinkAvCap.ui2_sink_colorimetry = SINK_RGB;
	HDMI_ATTR_SPRINTF("color = %d; deep = %d\n",
		_stAvdAVInfo.e_video_color_space,
		   _stAvdAVInfo.e_deep_color_bit);
	return 0;
}

static unsigned int set_cec_on(char *str_p)
{
	unsigned int cecon;
	unsigned int ui_cecon;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("cecon:0xPPP/0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x/0x%x", &cecon,
		&ui_cecon);
	if (ret != 2)
		return 0;

	HDMI_ATTR_SPRINTF("cecon = %d; ui_cecon = %d\n",
		cecon, ui_cecon);
	hdmi_cec_on = cecon;
	hdmi_uicec_on = ui_cecon;
	HDMI_ATTR_SPRINTF("hdmi_cec_on = %d; hdmi_uicec_on = %d\n",
		hdmi_cec_on,
		hdmi_uicec_on);
	return 0;
}


static unsigned int set_dolbyhdr(char *str_p)
{
	unsigned int dolbyhdren;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("dolbyen:0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x", &dolbyhdren);
	if (ret != 1)
		return 0;

	HDMI_ATTR_SPRINTF("dolbyhdren = %d\n", dolbyhdren);

	vDolbyHdrEnable(dolbyhdren);

	return 0;
}

static unsigned int set_hdcponoff(char *str_p)
{
	unsigned int hdcponoff;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("hdcponoff:0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x", &hdcponoff);
	if (ret != 1)
		return 0;

	HDMI_ATTR_SPRINTF("hdcponoff = %d\n", hdcponoff);

	if (hdcponoff) {
		vHDCPReset();
		_bHdcpOff = hdcponoff;
	} else {
		_bHdcpOff = hdcponoff;
		vHDCPInitAuth();
	}
	return 0;
}

static unsigned int set_hdmiioctl(char *str_p)
{
	unsigned int resolutionmode;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("hdmiioctl:0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x", &resolutionmode);
	if (ret != 1)
		return 0;

	HDMI_ATTR_SPRINTF("hdmiioctl = %d\n", resolutionmode);

	hdmi_video_config(resolutionmode);
	return 0;
}

static unsigned int set_hdmidebuglevel(char *str_p)
{
	unsigned int debuglevel;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("dbglevel:0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x", &debuglevel);
	if (ret != 1)
		return 0;

	HDMI_ATTR_SPRINTF("dbglevel = %d\n", debuglevel);

	hdmi_drvlog_enable(debuglevel);
	return 0;
}

static unsigned int set_cdr(void)
{
	vWriteIoHdmiAnaMsk(HDMI_1_CFG_0, 0, RG_HDMITX21_DRV_EN);
	vHdcpDdcHwPoll(FALSE);
	vSendTMDSConfiguration(3);
	udelay(100);
	vWriteIoHdmiAnaMsk(HDMI_1_CFG_0,
		RG_HDMITX21_DRV_EN, RG_HDMITX21_DRV_EN);
	return 0;
}

void vEnableHdmiPattern(int u4On, int u4Data)
{
	vWriteHdmiGRLMsk(TOP_CFG00, (u4Data << 16),
		ABIST_VIDEO_FORMAT_MASKBIT);
	vWriteHdmiGRLMsk(TOP_CFG00, (u4On << 31), ABIST_ENABLE);

}

static unsigned int set_hdmipattern(char *str_p)
{
	unsigned int ret = 0;
	unsigned int u4Data = 0, u4On = 0;

	ret = sscanf(str_p, "0x%x/0x%x", &u4On, &u4Data);
	if (ret != 2)
		return 0;

	vEnableHdmiPattern(u4On, u4Data);

	HDMI_ATTR_SPRINTF("///////comment start//////\n");
	HDMI_ATTR_SPRINTF("Value1:\n");
	HDMI_ATTR_SPRINTF("0x0: Pattern Off\n");
	HDMI_ATTR_SPRINTF("0x1: Pattern On\n");
	HDMI_ATTR_SPRINTF("Value 2(Pattern Type):\n");
	HDMI_ATTR_SPRINTF("0x2: 720*480P@60\n");
	HDMI_ATTR_SPRINTF("0x3: 1280*720P@60\n");
	HDMI_ATTR_SPRINTF("0x4: 1920*1080I@60\n");
	HDMI_ATTR_SPRINTF("0x5: 1440*480I@60\n");
	HDMI_ATTR_SPRINTF("0x9: 1440*480P@60\n");
	HDMI_ATTR_SPRINTF("0xA: 1920*1080P@60\n");
	HDMI_ATTR_SPRINTF("0xB: 720*576P@50\n");
	HDMI_ATTR_SPRINTF("0xC: 1280*720P@50\n");
	HDMI_ATTR_SPRINTF("0xD: 1920*1080I@50\n");
	HDMI_ATTR_SPRINTF("0xE: 1440*576I@50\n");
	HDMI_ATTR_SPRINTF("0x12: 1440*576P@50\n");
	HDMI_ATTR_SPRINTF("0x13: 1920*1080P@50\n");
	HDMI_ATTR_SPRINTF("0x18: 3840*2160P@25\n");
	HDMI_ATTR_SPRINTF("0x19: 3840*2160P@30\n");
	HDMI_ATTR_SPRINTF("0x1A: 4096*2160P@30\n");
	HDMI_ATTR_SPRINTF("////////comment end///////\n");

	return 0;
}

static unsigned int set_readirq(char *str_p)
{
	vShowIrqRegister();

	return 0;
}

static unsigned int set_power_onoff(char *str_p)
{
	unsigned int u4on;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("setpower:0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x", &u4on);
	if (ret != 1)
		return 0;

	if (u4on != 0) {
		hdmi_internal_power_on();
		HDMI_ATTR_SPRINTF("hdmi_internal_power_on\n");
		hdmi_video_config(0xd);
	} else {
		hdmi_internal_power_off();
		HDMI_ATTR_SPRINTF("hdmi_internal_power_off\n");
	}
	return 0;
}

static unsigned int power_test(char *str_p)
{
	unsigned int u4on;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("setpower:0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x", &u4on);
	if (ret != 1)
		return 0;

	if (u4on != 0) {
		hdmi_power_on();
		HDMI_ATTR_SPRINTF("hdmi_power_on\n");
	} else {
		hdmi_power_off();
		HDMI_ATTR_SPRINTF("hdmi_power_off\n");
	}
	return 0;
}

static unsigned int hdmi_hdcp_version(void)
{
#if (defined(CONFIG_MTK_IN_HOUSE_TEE_SUPPORT) || defined(CONFIG_OPTEE))
	fgCaHDMITestHDCPVersion();
#endif
	return 0;
}

static unsigned int _ReadReg(char *str_p)
{
	unsigned int u4Data = 0;
	unsigned long u4Addr = 0;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("rg:0xPPPPPPPP\n");
		return 0;
	}
	ret = sscanf(str_p, "0x%lx", &u4Addr);
	if (ret != 1)
		return 0;

	u4Data = *(unsigned int *)u4Addr;
	HDMI_ATTR_SPRINTF("0x%lx = 0x%08x\n", u4Addr, u4Data);
	return TRUE;
}

static unsigned int _WriteReg(char *str_p)
{
	unsigned int u4Data = 0;
	unsigned long u4Addr = 0;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("wg:0xPPPPPPPP/0xPPPPPPPP\n");
		return 0;
	}
	ret = sscanf(str_p, "0x%lx=0x%x", &u4Addr, &u4Data);
	if (ret != 2)
		return 0;

	*(unsigned int *)u4Addr = u4Data;
	u4Data = *(unsigned int *)u4Addr;
	HDMI_ATTR_SPRINTF("0x%lx = 0x%08x\n", u4Addr, u4Data);
	return TRUE;
}

static unsigned int _ReadReg_Range(char *str_p)
{
	unsigned int u4Data = 0;
	unsigned long u4Addr = 0;
	unsigned int u4Count = 0;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("rg:0xPPPPPPPP/0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%lx/0x%x", &u4Addr, &u4Count);
	if (ret != 2)
		return 0;

	while (u4Count >= 4) {
		u4Data = *(unsigned int *)u4Addr;
		HDMI_ATTR_SPRINTF("0x%lx = 0x%08x\n", u4Addr, u4Data);
		HAL_Delay_us(2);
		u4Addr = u4Addr + 4;
		u4Count = u4Count - 4;
	}

	return 0;
}

static unsigned int read_phy_reg(unsigned int addr,
	unsigned int *u4Data)
{
	if (addr >= 0x1a000000) {
		internal_hdmi_read(hdmi_reg[REG_HDMI_DIG] +
			addr - 0x1a000000, u4Data);
		HDMI_ATTR_SPRINTF("1 0x%08x = 0x%08x\n",
			addr, *u4Data);
	} else if (addr >= 0x14001800) {
		internal_hdmi_read(hdmi_reg[REG_HDMI_RGB2HDMI] +
			addr - 0x14001800, u4Data);
		HDMI_ATTR_SPRINTF("3 0x%08x = 0x%08x\n",
			addr, *u4Data);
	} else if (addr >= 0x11f30000) {
		internal_hdmi_read(hdmi_reg[REG_HDMI_ANA] +
			addr - 0x11f30000, u4Data);
		HDMI_ATTR_SPRINTF("4 0x%08x = 0x%08x\n",
			addr, *u4Data);
	} else if (addr >= 0x10014000) {
		internal_hdmi_read(hdmi_reg[REG_HDMI_CEC] +
			addr - 0x10014000, u4Data);
		HDMI_ATTR_SPRINTF("5 0x%08x = 0x%08x\n",
			addr, *u4Data);
	} else if (addr >= 10000000) {
		internal_hdmi_read(hdmi_ref_reg[MMSYS_CONFIG] +
			addr - 0x10000000, u4Data);
		HDMI_ATTR_SPRINTF("7 0x%08x = 0x%08x\n",
			addr, *u4Data);
	} else {
		HDMI_ATTR_SPRINTF(
		"%s the address is over of the range: 0x%08x\n",
		__func__, *u4Data);
		HDMI_ATTR_SPRINTF("8 0x%08x = 0x%08x\n",
			addr, *u4Data);
	}
	return *u4Data;
}

static unsigned int hdmi_read_reg(char *str_p)
{
	unsigned int u4Data = 0;
	unsigned int u4Addr = 0;
	int ret = 0;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("rg:0xPPPPPPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x", &u4Addr);
	if (ret != 1)
		return 0;

	if (u4Addr >= 0x1a000000) {
		internal_hdmi_read(hdmi_reg[REG_HDMI_DIG] +
			u4Addr - 0x1a000000, &u4Data);
		HDMI_ATTR_SPRINTF("1 0x%08x = 0x%08x\n",
			u4Addr, u4Data);
	} else if (u4Addr >= 0x14001800) {
		internal_hdmi_read(hdmi_reg[REG_HDMI_RGB2HDMI] +
			u4Addr - 0x14001800, &u4Data);
		HDMI_ATTR_SPRINTF("3 0x%08x = 0x%08x\n",
			u4Addr, u4Data);
	} else if (u4Addr >= 0x14001000) {
		internal_hdmi_read(hdmi_reg[REG_HDMI_VDOUT] +
			u4Addr - 0x14001000, &u4Data);
		HDMI_ATTR_SPRINTF("3 0x%08x = 0x%08x\n",
			u4Addr, u4Data);
	} else if (u4Addr >= 0x11f30000) {
		internal_hdmi_read(hdmi_reg[REG_HDMI_ANA] +
			u4Addr - 0x11f30000, &u4Data);
		HDMI_ATTR_SPRINTF("4 0x%08x = 0x%08x\n",
			u4Addr, u4Data);
	} else if (u4Addr >= 0x10014000) {
		internal_hdmi_read(hdmi_reg[REG_HDMI_CEC] +
			u4Addr - 0x10014000, &u4Data);
		HDMI_ATTR_SPRINTF("5 0x%08x = 0x%08x\n",
			u4Addr, u4Data);
	} else if (u4Addr >= 10000000) {
		internal_hdmi_read(hdmi_ref_reg[MMSYS_CONFIG] +
			u4Addr - 0x10000000, &u4Data);
		HDMI_ATTR_SPRINTF("7 0x%08x = 0x%08x\n",
			u4Addr, u4Data);
	} else {
		HDMI_ATTR_SPRINTF(
	"%s the address is over of the range: 0x%08x\n",
	__func__, u4Addr);
		HDMI_ATTR_SPRINTF("8 0x%08x = 0x%08x\n",
			u4Addr, u4Data);
	}

	HDMI_ATTR_SPRINTF("0x%08x = 0x%08x\n", u4Addr, u4Data);

	return 0;
}

static unsigned int hdmi_read_reg_range(char *str_p)
{
	unsigned int u4Data = 0;
	unsigned int u4Addr = 0;
	unsigned int u4Count = 0;
	void __iomem *va_addr = NULL;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("rg:0xPPPPPPPP/0xPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x/0x%x", &u4Addr, &u4Count);
	if (ret != 2)
		return 0;

	while (u4Count >= 4) {
		if (u4Addr >= 0x1a000000)
			internal_hdmi_read(hdmi_reg[REG_HDMI_DIG] +
			u4Addr - 0x1a000000, &u4Data);
		else if (u4Addr >= 0x14001800)
			internal_hdmi_read(hdmi_reg[REG_HDMI_RGB2HDMI] +
			u4Addr - 0x14001800, &u4Data);
		else if (u4Addr >= 0x11f30000)
			internal_hdmi_read(hdmi_reg[REG_HDMI_ANA] +
			u4Addr - 0x11f30000, &u4Data);
		else if (u4Addr >= 0x10014000)
			internal_hdmi_read(hdmi_reg[REG_HDMI_CEC] +
			u4Addr - 0x10014000, &u4Data);
		else if (u4Addr >= 10000000)
			internal_hdmi_read(hdmi_ref_reg[MMSYS_CONFIG] +
			u4Addr - 0x10000000, &u4Data);
		else
			HDMI_ATTR_SPRINTF(
	"%s the address is over of the range: 0x%08x\n",
	__func__, u4Addr);

		HDMI_ATTR_SPRINTF("0x%08x = 0x%08x\n", u4Addr, u4Data);
		HAL_Delay_us(2);
		u4Addr = u4Addr + 4;
		va_addr = va_addr + 4;
		u4Count = u4Count - 4;
	}

	return 0;
}

static void write_phy_reg(unsigned int u4Addr, unsigned int u4Data)
{
	if (u4Addr >= 0x1a000000)
		internal_hdmi_write(hdmi_reg[REG_HDMI_DIG] +
		u4Addr - 0x1a000000, u4Data);
	else if (u4Addr >= 0x14006C00) {
#if (defined(CONFIG_MTK_IN_HOUSE_TEE_SUPPORT) || defined(CONFIG_OPTEE))
		HDMI_ATTR_SPRINTF("CONFIG_TEE_SUPPORT\n");
		vCaHDMIWriteReg(u4Addr - 0x14006c00, u4Data);
#else
		HDMI_ATTR_SPRINTF("CONFIG_TEE_SUPPORT Fail\n");
		internal_hdmi_write(hdmi_reg[REG_HDMI_DIG] +
			u4Addr - 0x14006c00, u4Data);
#endif
	} else if (u4Addr >= 0x14001800)
		internal_hdmi_write(hdmi_reg[REG_HDMI_RGB2HDMI] +
		u4Addr - 0x14001800, u4Data);
	else if (u4Addr >= 0x11f30000)
		internal_hdmi_write(hdmi_reg[REG_HDMI_ANA] +
		u4Addr - 0x11f30000, u4Data);
	else if (u4Addr >= 0x10014000)
		internal_hdmi_write(hdmi_reg[REG_HDMI_CEC] +
		u4Addr - 0x10014000, u4Data);
	else if (u4Addr >= 10000000)
		internal_hdmi_write(hdmi_ref_reg[MMSYS_CONFIG] +
		u4Addr - 10000000, u4Data);
	else
		HDMI_ATTR_SPRINTF(
	"%s the address is over of the range: 0x%08x\n",
	__func__, u4Data);

}

static unsigned int hdmi_write_reg(char *str_p)
{
	unsigned int u4Data = 0;
	unsigned int u4Addr = 0;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("wg:0xPPPPPPPP=0xPPPPPPPP\n");
		return 0;
	}

	ret = sscanf(str_p, "0x%x=0x%x", &u4Addr, &u4Data);
	if (ret != 2)
		return 0;

	if (u4Addr >= 0x1a000000) {
#if (defined(CONFIG_MTK_IN_HOUSE_TEE_SUPPORT) || defined(CONFIG_OPTEE))
		vCaHDMIWriteReg(u4Addr - 0x1a000000, u4Data);
#else
		internal_hdmi_write(hdmi_reg[REG_HDMI_DIG] +
		u4Addr - 0x1a000000, u4Data);
#endif
	} else if (u4Addr >= 0x14001800)
		internal_hdmi_write(hdmi_reg[REG_HDMI_RGB2HDMI] +
		u4Addr - 0x14001800, u4Data);
	else if (u4Addr >= 0x14001000)
		internal_hdmi_write(hdmi_reg[REG_HDMI_VDOUT] +
		u4Addr - 0x14001000, u4Data);
	else if (u4Addr >= 0x11f30000)
		internal_hdmi_write(hdmi_reg[REG_HDMI_ANA] +
		u4Addr - 0x11f30000, u4Data);
	else if (u4Addr >= 0x10014000)
		internal_hdmi_write(hdmi_reg[REG_HDMI_CEC] +
		u4Addr - 0x10014000, u4Data);
	else if (u4Addr >= 10000000)
		internal_hdmi_write(hdmi_ref_reg[MMSYS_CONFIG] +
		u4Addr - 10000000, u4Data);
	else
		HDMI_ATTR_SPRINTF(
	"%s the address is over of the range: 0x%08x\n",
	__func__, u4Addr);

	HDMI_ATTR_SPRINTF("0x%08x = 0x%08x\n", u4Addr, u4Data);

	return 0;
}

static void hdmi_write_reg_mask(char *str_p)
{
	unsigned int u4Data = 0;
	unsigned int u4Addr = 0;
	unsigned int mask = 0;
	unsigned int tmp = 0;
	int ret = 0;

	if (strncmp(str_p, "help", 4) == 0) {
		HDMI_ATTR_SPRINTF("wg:0xPPPPPPPP=0xPPPPPPPP\n");
		return;
	}
	ret = sscanf(str_p, "0x%x=0x%x-m0x%x", &u4Addr, &u4Data, &mask);
	if (ret != 3)
		return 0;

	read_phy_reg(u4Addr, &tmp);
	tmp &= (~mask);
	tmp |= (u4Data & mask);
	write_phy_reg(u4Addr, tmp);
}

static void set_hdr10p_ediden(char *str_p)
{
	unsigned int en, version, ret;

	ret = sscanf(str_p, "0x%x,0x%x", &en, &version);
	if (ret != 2)
		return;

	HDMI_ATTR_SPRINTF("hdr10p_ediden = %d, version=%d\n",
		debug_hdr10p_force_enable_edid,
		debug_hdr10p_force_set_appversion);
	debug_hdr10p_force_enable_edid = en;

	if (version != 0)
		debug_hdr10p_force_set_appversion = version;
	HDMI_ATTR_SPRINTF("hdr10p_ediden = %d, version=%d\n",
		debug_hdr10p_force_enable_edid,
		debug_hdr10p_force_set_appversion);
}

static void set_cec_enable(char *str_p)
{
	unsigned int en, ret;

	ret = sscanf(str_p, "0x%x", &en);
	if (ret != 1)
		return;

	TX_DEF_LOG("cec en=%d\n", en);
	hdmi_CECMWSetEnableCEC(en);
}

static void set_hdmi_unmute(char *str_p)
{
	unsigned int en, ret;

	ret = sscanf(str_p, "0x%x", &en);
	if (ret != 1)
		return;

	TX_DEF_LOG("mute=%d\n", en);
#if (defined(CONFIG_MTK_IN_HOUSE_TEE_SUPPORT) || defined(CONFIG_OPTEE))
	if (en == 1)
		vCaHDMIWriteHdcpCtrl(0x88880000, 0xaaaaaaaa);
	else
		vCaHDMIWriteHdcpCtrl(0x88880000, 0x55555555);
	vHDMIAVUnMute();
#endif
}

static void _HdrEnable(char *str_p)
{
	unsigned int ret;
	unsigned int fgHdrEnable, fgBT2020Enable, fgDolbyHdrEnable;

	ret = sscanf(str_p, "0x%x/0x%x/0x%x", &fgHdrEnable,
		&fgBT2020Enable, &fgDolbyHdrEnable);
	if (ret != 3)
		return;

	if (fgHdrEnable == 3) {
		_bStaticHdrStatus = HDR_PACKET_DISABLE;
		vHalSendStaticHdrInfoFrame(_bStaticHdrStatus,
		_bHdrMetadataBuff);
	} else if (fgHdrEnable == 4) {
		_bStaticHdrStatus = HDR_PACKET_ACTIVE;
		vHalSendStaticHdrInfoFrame(_bStaticHdrStatus,
		_bHdrMetadataBuff);
	} else if (fgHdrEnable == 5) {
		_bStaticHdrStatus = HDR_PACKET_ZERO;
		vHalSendStaticHdrInfoFrame(_bStaticHdrStatus,
		_bHdrMetadataBuff);
	} else {
		vHdrEnable(fgHdrEnable);
		vBT2020Enable(fgBT2020Enable);
		vDolbyHdrEnable(fgDolbyHdrEnable);
	}
}

static void _Hdmi_clk_debug(char *str_p)
{
	unsigned int ret;
	unsigned int fgEnable, bClk;

	ret = sscanf(str_p, "0x%x/0x%x", &fgEnable, &bClk);
	if (ret != 2)
		return;

	hdmi_clock_debug(fgEnable, bClk);
}

static void _HdrDisable(char *str_p)
{
	unsigned int ret;
	unsigned int u4HdrDebugDisableType;

	ret = sscanf(str_p, "0x%x", &u4HdrDebugDisableType);
	if (ret != 1)
		return;

	vSetHdrDebugType(u4HdrDebugDisableType);
}

void hdmi_show_cec_status(void)
{
	unsigned char *str;

	str = kmalloc(4096, GFP_KERNEL);
	hdmi_cec_status_dump(str);
	HDMI_ATTR_SPRINTF("%s\n", str);
	kfree(str);
}

static void set_hpd_status(char *str_p)
{
	unsigned int status, ret;

	ret = sscanf(str_p, "0x%x", &status);
	if (ret != 1)
		return;

	HDMI_ATTR_SPRINTF("debug_force_hotplug old =%d\n",
		debug_force_hotplug);
	debug_force_hotplug = status;

	switch (debug_force_hotplug) {
	case HDMI_STATE_HOT_PLUG_OUT:
		HDMI_ATTR_SPRINTF(
	"enable force HDMI_STATE_HOT_PLUG_OUT\n");
		break;
	case HDMI_STATE_HOT_PLUGIN_AND_POWER_ON:
		HDMI_ATTR_SPRINTF(
	"enable force HDMI_STATE_HOT_PLUGIN_AND_POWER_ON\n");
		break;
	case HDMI_STATE_HOT_PLUG_IN_ONLY:
		HDMI_ATTR_SPRINTF(
	"enable force HDMI_STATE_HOT_PLUG_IN_ONLY\n");
		break;
	default:
		HDMI_ATTR_SPRINTF(
	"disable force ,debug_force_hotplug=%d\n", debug_force_hotplug);
		break;
	}
	dbg_wakeup_hdmi_irqwq();
}

static void hdmi_test_mode(char *str_p)
{
	unsigned int temp, temp1, temp2;
	int ret;

	if (strncmp(str_p, "help", 4) == 0) {
		TX_DEF_LOG("0:av mute pkt\n");
		TX_DEF_LOG("1:av unmute pkt\n");
		return;
	}

	ret = sscanf(str_p, "%d,%d", &temp, &temp1);
	if (ret != 2)
		return;

	if (temp == 0) {
		TX_DEF_LOG("av mute pkt\n");
		vSend_AVMUTE();
	} else if (temp == 1) {
		TX_DEF_LOG("av unmute pkt\n");
		vSend_AVUNMUTE();
	} else if (temp == 2) {
		if (temp1 == 0) {
			hdmi_timing_monitor_stop();
			hdmi_clock_read(0);
			TX_DEF_LOG("hdmi_timing_monitor_stop\n");
		} else if (temp1 == 1) {
			hdmi_timing_monitor_start();
			TX_DEF_LOG("hdmi_timing_monitor_start\n");
		} else if (temp1 == 2) {
			TX_DEF_LOG("check clk, %d\n", pll_read_state);
			hdmi_timing_monitor_sel(0);
			hdmi_clock_read(2);
			usleep_range(1000, 1050);
			temp2 = hdmi_clock_read(1);
			TX_DEF_LOG("pixel clk = %d, %d\n", temp2,
				(temp2 * 52000) / 1024);
			hdmi_timing_monitor_sel(1);
			hdmi_clock_read(2);
			usleep_range(1000, 1050);
			temp2 = hdmi_clock_read(1);
			TX_DEF_LOG("tmds clk = %d, %d\n", temp2,
				(temp2 * 52000) / 1024);
		}
	} else if (temp == 10) {
		TX_DEF_LOG("load_bin_flag = FALSE\n");
		load_bin_flag = FALSE;
	}
}

static void get_freq_meter(unsigned char mode)
{
	unsigned int clockFreq;

	if (mode == 1) //pixel clock
		vWriteHdmiGRLMsk(0x1a4, 0x0 << 5, 0x3 << 5);
	else if (mode == 2) //tmds clock
		vWriteHdmiGRLMsk(0x1a4, 0x1 << 5, 0x3 << 5);
	else if (mode == 3) //i2s sck
		vWriteHdmiGRLMsk(0x1a4, 0x2 << 5, 0x3 << 5);
	else //i2s lrck
		vWriteHdmiGRLMsk(0x1a4, 0x3 << 5, 0x3 << 5);

	vWriteByteHdmiGRL(0x1d4, 0x000007ff);
	vWriteHdmiGRLMsk(0x1d0, 0x1 << 0, 0x1 << 0);

	udelay(40);

	clockFreq = bReadByteHdmiGRL(0x1d4);
	clockFreq = clockFreq >> 16;
	clockFreq = clockFreq * 52000 / 1024;

	HDMI_ATTR_SPRINTF("clock freq meter is %d\n", clockFreq);
}

/* ------------------------------------------ */
/* Debug FileSystem Routines */
/* ------------------------------------------ */
static void process_dbg_cmd(char *opt)
{
	char *oprand;
	int ret, i, size, en;
	char testbuf[500] = {0};
	struct VID_PLA_HDR_METADATA_INFO_T hdr_metadata;

	if (strncmp(opt, "r:", 2) == 0)
		_ReadReg(opt + 2);
	else if (strncmp(opt, "w:", 2) == 0)
		_WriteReg(opt + 2);
	else if (strncmp(opt, "rr:", 3) == 0)
		_ReadReg_Range(opt + 3);
	else if (strncmp(opt, "rg:", 3) == 0)
		hdmi_read_reg(opt + 3);
	else if (strncmp(opt, "wg:", 3) == 0)
		hdmi_write_reg(opt + 3);
	else if (strncmp(opt, "wgm:", 4) == 0)
		hdmi_write_reg_mask(opt + 4);
	else if (strncmp(opt, "rrg:", 4) == 0)
		hdmi_read_reg_range(opt + 4);
	else if (strncmp(opt, "settxpll:", 9) == 0)
		SetHDMITXPLL(opt + 9);
	else if (strncmp(opt, "sethdmi:", 8) == 0)
		set_hdmi_output_hdmi(opt + 8);
	else if (strncmp(opt, "fixvideo:", 9) == 0)
		set_hdmi_video_config(opt + 9);
	else if (strncmp(opt, "fixpmx:", 7) == 0)
		set_pmx_parameter(opt + 7);
	else if (strncmp(opt, "readedid:", 9) == 0)
		hdmi_read_edid(opt + 9);
	else if (strncmp(opt, "status", 6) == 0)
		hdmi_status();
	else if (strncmp(opt, "setaud", 6) == 0)
		set_hdmi_audio_config();
	else if (strncmp(opt, "setpower:", 9) == 0)
		set_power_onoff(opt + 9);
	else if (strncmp(opt, "codeep:", 7) == 0)
		set_colordeep(opt + 7);
	else if (strncmp(opt, "cecon:", 6) == 0)
		set_cec_on(opt + 6);
	else if (strncmp(opt, "dolbyhdr:", 9) == 0)
		set_dolbyhdr(opt + 9);
	else if (strncmp(opt, "readirq", 7) == 0)
		set_readirq(opt + 7);
	else if (strncmp(opt, "hdcp:", 5) == 0)
		set_hdcponoff(opt + 5);
	else if (strncmp(opt, "setcdr", 6) == 0)
		set_cdr();
	else if (strncmp(opt, "hdmipat:", 8) == 0)
		set_hdmipattern(opt + 8);
	else if (strncmp(opt, "hdmiioctl:", 10) == 0)
		set_hdmiioctl(opt + 10);
	else if (strncmp(opt, "dbglevel:", 9) == 0)
		set_hdmidebuglevel(opt + 9);
	else if (strncmp(opt, "hdr10p:", 7) == 0)
		set_hdr10p_ediden(opt + 7);
	else if (strncmp(opt, "showedid", 8) == 0)
		mt_hdmi_show_edid_info();
	else if (strncmp(opt, "sethpd:", 7) == 0)
		set_hpd_status(opt + 7);
	else if (strncmp(opt, "cectest", 7) == 0) {
		if (hdmi_cec_factory_test())
			HDMI_ATTR_SPRINTF("[HDMI TX] CEC test pass!\n");
		else
			HDMI_ATTR_SPRINTF("[HDMI TX] CEC fail!\n");
	} else if (strncmp(opt, "irq:on", 6) == 0) {
		HDMI_ATTR_SPRINTF("[hdmi] irq on\n");
		HDMI_EnableIrq();
	} else if (strncmp(opt, "irq:off", 7) == 0) {
		HDMI_ATTR_SPRINTF("[hdmi] irq off\n");
		HDMI_DisableIrq();
	} else if (strncmp(opt, "hdrstatus", 9) == 0) {
		mt_hdmi_show_hdr_status();
	} else if (strncmp(opt, "cecen:", 6) == 0) {
		set_cec_enable(opt + 6);
	} else if (strncmp(opt, "unmute:", 7) == 0) {
		set_hdmi_unmute(opt + 7);
	} else if (strncmp(opt, "audreset", 8) == 0) {
		vResetAudioHDMI(1);
	} else if (strncmp(opt, "vidreset", 8) == 0) {
		vResetVideoHDMI(1);
	} else if (strncmp(opt, "audpacket:", 10) == 0) {
		ret = sscanf(opt+10, "%x", &en);
		if (ret < 1)
			return;
		if (en)
			vAudioPacketOff(1);
		else
			vAudioPacketOff(0);

	} else if (strncmp(opt, "audcfg", 6) == 0) {
		struct HDMITX_AUDIO_PARA audio_setting;
		char *arg = NULL;
		int value = 0;

		oprand = strsep(&opt, "=");
		if (oprand == NULL)
			goto Error;
		arg = strsep(&opt, ",");
		if (arg == NULL)
			goto Error;
		if (kstrtoint(arg, 10, &value))
			goto Error;
		audio_setting.e_hdmi_aud_in = (value & 0xff);
		arg = strsep(&opt, ",");
		TX_DEF_LOG("1arg=%s\n", arg);
		if (arg == NULL)
			goto Error;
		if (kstrtoint(arg, 10, &value))
			goto Error;
		audio_setting.e_iec_frame = (value & 0xff);
		arg = strsep(&opt, ",");
		TX_DEF_LOG("2arg=%s\n", arg);
		if (arg == NULL)
			goto Error;
		if (kstrtoint(arg, 10, &value))
			goto Error;
		audio_setting.e_hdmi_fs = (value & 0xff);
		arg = strsep(&opt, ",");
		if (arg == NULL)
			goto Error;
		if (kstrtoint(arg, 10, &value))
			goto Error;
		audio_setting.e_aud_code = (value & 0xff);
		arg = strsep(&opt, ",");
		if (arg == NULL)
			goto Error;
		if (kstrtoint(arg, 10, &value))
			goto Error;
		audio_setting.e_I2sFmt = (value & 0xff);
		arg = strsep(&opt, ",");
		if (arg == NULL)
			goto Error;
		if (kstrtoint(arg, 10, &value))
			goto Error;
		audio_setting.u1HdmiI2sMclk = (value & 0xff);
		arg = strsep(&opt, ",");
		if (arg == NULL)
			goto Error;
		if (kstrtoint(arg, 10, &value))
			goto Error;
		audio_setting.u1Aud_Input_Chan_Cnt = (value & 0xff);
		audio_setting.bhdmi_LCh_status[0] = 0;
		audio_setting.bhdmi_LCh_status[1] = 0;
		audio_setting.bhdmi_LCh_status[2] = 2;
		audio_setting.bhdmi_LCh_status[3] = 0;
		audio_setting.bhdmi_LCh_status[4] = 0;
		audio_setting.bhdmi_RCh_status[0] = 0;
		audio_setting.bhdmi_RCh_status[1] = 0;
		audio_setting.bhdmi_RCh_status[2] = 2;
		audio_setting.bhdmi_RCh_status[3] = 0;
		audio_setting.bhdmi_RCh_status[4] = 0;
		hdmi_audiosetting(&audio_setting);
	} else if (strncmp(opt, "sdr", 3) == 0) {
		vHdr10PlusEnable(false);
	} else if (strncmp(opt, "dovistd:", 8) == 0) {
		ret = sscanf(opt+8, "%x", &en);
		if (ret < 1)
			return;
		vHdr10PlusEnable(false);
		vDolbyHdrEnable(en);
	} else if (strncmp(opt, "dovill:", 7) == 0) {
		ret = sscanf(opt+7, "%x", &en);
		if (ret < 1)
			return;
		memset(&hdr_metadata, 0, sizeof(hdr_metadata));
		if (en) {
			vHdr10PlusEnable(false);
			vLowLatencyDolbyVisionEnable(false);
			hdr_metadata.e_DynamicRangeType =
				VID_PLA_DR_TYPE_DOVI_LOWLATENCY;
			hdr_metadata.metadata_info
				.dovi_lowlatency_metadata
				.fgBackltCtrlMdPresent = 0;
			hdr_metadata.metadata_info
				.dovi_lowlatency_metadata.ui4_EffTmaxPQ = 0;
			vVdpSetHdrMetadata(true, hdr_metadata);
			vLowLatencyDolbyVisionEnable(true);
		} else
			vLowLatencyDolbyVisionEnable(false);
	} else if (strncmp(opt, "hlg:", 4) == 0) {
		ret = sscanf(opt+4, "%x", &en);
		if (ret < 1)
			return;
		memset(&hdr_metadata, 0, sizeof(hdr_metadata));
		if (en) {
			vHdr10PlusEnable(false);
			vHdrEnable(false);
			hdr_metadata.e_DynamicRangeType = VID_PLA_DR_TYPE_HDR10;
			hdr_metadata.metadata_info.hdr10_metadata
				.ui2_DisplayPrimariesX[0] = 0x8a48;
			 hdr_metadata.metadata_info.hdr10_metadata
				.ui2_DisplayPrimariesY[0] = 0x3908;
			hdr_metadata.metadata_info.hdr10_metadata
				.ui2_DisplayPrimariesX[1] = 0x2134;
			hdr_metadata.metadata_info.hdr10_metadata
				.ui2_DisplayPrimariesY[1] = 0x9baa;
			hdr_metadata.metadata_info.hdr10_metadata
				.ui2_DisplayPrimariesX[2] = 0x1996;
			hdr_metadata.metadata_info.hdr10_metadata
				.ui2_DisplayPrimariesY[2] = 0x1996;
			hdr_metadata.metadata_info.hdr10_metadata
				.ui2_WhitePointX = 0x3d13;
			hdr_metadata.metadata_info.hdr10_metadata
				.ui2_WhitePointY = 0x4042;
			hdr_metadata.metadata_info.hdr10_metadata
				.ui2_MaxDisplayMasteringLuminance = 0xfa0;
			hdr_metadata.metadata_info.hdr10_metadata
				.ui2_MinDisplayMasteringLuminance = 0x32;
			hdr_metadata.metadata_info.hdr10_metadata
				.ui2_MaxCLL = 0x2222;
			hdr_metadata.metadata_info.hdr10_metadata
				.ui2_MaxFALL = 0x79;
			vSetStaticHdrType(GAMMA_HLG);
			vVdpSetHdrMetadata(true, hdr_metadata);
			vHdrEnable(true);
		} else
			vHdrEnable(false);
	} else if (strncmp(opt, "hdr10gst:", 9) == 0) {
		ret = sscanf(opt+9, "%x", &en);
		if (ret < 1)
			return;
		memset(&hdr_metadata, 0, sizeof(hdr_metadata));
		HDMI_ATTR_SPRINTF("en=%x\n", en);
		if (en) {
			vHdr10PlusEnable(false);
			vHdrEnable(false);
			hdr_metadata.e_DynamicRangeType = VID_PLA_DR_TYPE_HDR10;
			hdr_metadata.metadata_info
				.hdr10_metadata
				.ui2_DisplayPrimariesX[0] = 0x8a48;
			hdr_metadata.metadata_info
				.hdr10_metadata
				.ui2_DisplayPrimariesY[0] = 0x3908;
			hdr_metadata.metadata_info
				.hdr10_metadata
				.ui2_DisplayPrimariesX[1] = 0x2134;
			hdr_metadata.metadata_info
				.hdr10_metadata
				.ui2_DisplayPrimariesY[1] = 0x9baa;
			hdr_metadata.metadata_info
				.hdr10_metadata
				.ui2_DisplayPrimariesX[2] = 0x1996;
			hdr_metadata.metadata_info
				.hdr10_metadata
				.ui2_DisplayPrimariesY[2] = 0x1996;
			hdr_metadata.metadata_info
				.hdr10_metadata.ui2_WhitePointX = 0x3d13;
			hdr_metadata.metadata_info
				.hdr10_metadata.ui2_WhitePointY = 0x4042;
			hdr_metadata.metadata_info
				.hdr10_metadata
				.ui2_MaxDisplayMasteringLuminance = 0xfa0;
			hdr_metadata.metadata_info
				.hdr10_metadata
				.ui2_MinDisplayMasteringLuminance = 0x32;
			hdr_metadata.metadata_info
				.hdr10_metadata.ui2_MaxCLL = 0x2222;
			hdr_metadata.metadata_info
				.hdr10_metadata.ui2_MaxFALL = 0x79;

			vSetStaticHdrType(GAMMA_ST2084);
			vVdpSetHdrMetadata(true, hdr_metadata);
			vHdrEnable(true);
		} else
			vHdrEnable(false);
	} else if (strncmp(opt, "hdr10emp:", 9) == 0) {
		ret = sscanf(opt+9, "%x", &en);
		if (ret < 1)
			return;
		memset(&hdr_metadata, 0, sizeof(hdr_metadata));
		HDMI_ATTR_SPRINTF("en=%x\n", en);
		if (en) {
			vHdr10PlusEnable(false);
			hdr_metadata.e_DynamicRangeType =
				VID_PLA_DR_TYPE_HDR10_PLUS;
			size = 300;
			hdr_metadata.metadata_info
				.hdr10_plus_metadata.hdr10p_metadata_info
				.ui4_Hdr10PlusSize =
				size;
			hdr_metadata.metadata_info
				.hdr10_plus_metadata.hdr10p_metadata_info
				.ui4_Hdr10PlusAddr =
				(unsigned long)(&testbuf);
			for (i = 0; i < size; i++)
				testbuf[i] = (i % 255);
			vVdpSetHdrMetadata(true, hdr_metadata);
			vHdr10PlusEnable(true);
		} else
			vHdr10PlusEnable(false);
	} else if (strncmp(opt, "hdr10pvsif:", 11) == 0) {
		ret = sscanf(opt+11, "%x", &en);
		if (ret < 1)
			return;
		memset(&hdr_metadata, 0, sizeof(hdr_metadata));
		if (en) {
			vHdr10PlusEnable(false);
			vHdr10PlusVSIFEnable(false);
			hdr_metadata.e_DynamicRangeType =
				VID_PLA_DR_TYPE_HDR10_PLUS_VSIF;
			size = 27;
			hdr_metadata.metadata_info
				.hdr10_plus_metadata
				.hdr10p_metadata_info.ui4_Hdr10PlusSize =
				size;
			hdr_metadata.metadata_info
				.hdr10_plus_metadata
				.hdr10p_metadata_info.ui4_Hdr10PlusAddr =
				(unsigned long)(&testbuf);
			for (i = 0; i < size; i++)
				testbuf[i] = (i % 255);
			vVdpSetHdrMetadata(true, hdr_metadata);
			vHdr10PlusVSIFEnable(true);
		} else
			vHdr10PlusVSIFEnable(false);
	} else if (strncmp(opt, "vidmute:", 8) == 0) {
		ret = sscanf(opt+8, "%x", &en);
		if (ret < 1)
			return;
		if (en)
			vBlackHDMIOnly();
		else
			vUnBlackHDMIOnly();
	} else if (strncmp(opt, "audmute:", 8) == 0) {
		ret = sscanf(opt+8, "%x", &en);
		if (ret < 1)
			return;
		if (en)
			MuteHDMIAudio();
		else
			UnMuteHDMIAudio();
	} else if (strncmp(opt, "hdren:", 6) == 0) {
		_HdrEnable(opt + 6);
	} else if (strncmp(opt, "hdrdis:", 7) == 0) {
		_HdrDisable(opt + 7);
	} else if (strncmp(opt, "powertest:", 10) == 0) {
		power_test(opt + 10);
	} else if (strncmp(opt, "hdcpver", 7) == 0) {
		hdmi_hdcp_version();
	} else if (strncmp(opt, "hdcpinfo", 8) == 0) {
		hdmi_show_hdcp_information();
	} else if (strncmp(opt, "clkdebug:", 9) == 0) {
		_Hdmi_clk_debug(opt + 9);
	} else if (strncmp(opt, "cecstatus", 9) == 0) {
		hdmi_show_cec_status();
	} else if (strncmp(opt, "cecmode:", 8) == 0) {
		ret = sscanf(opt+8, "%x", &en);
		if (ret < 1)
			return;
		HDMI_ATTR_SPRINTF("1 hdmi_rxcecmode=%x\n", hdmi_rxcecmode);
		hdmi_rxcecmode = en;
		HDMI_ATTR_SPRINTF("2 hdmi_rxcecmode=%x\n", hdmi_rxcecmode);
	}  else if (strncmp(opt, "getfreqmeter:", 13) == 0) {
		unsigned char mode;

		ret = sscanf(opt+13, "%x", &mode);
		if (ret < 1)
			return;
		get_freq_meter(mode);
	} else if (strncmp(opt, "setrptmode:", 11) == 0) {
		unsigned int mode;

		ret = sscanf(opt+11, "%x", &mode);
		if (ret < 1)
			return;
		vSetRptMode(mode);
	} else if (strncmp(opt, "audioconfig:", 12) == 0) {
		unsigned char bHDMIFsFreq;
		unsigned char bResolution;
		unsigned char bdeepmode;

		ret = sscanf(opt+12, "%x/%x/%x", &bHDMIFsFreq,
			&bResolution, &bdeepmode);
		if (ret < 1)
			return;
		vChgHDMIAudioOutput(bHDMIFsFreq,
			bResolution, bdeepmode);
	} else if (strncmp(opt, "settx:", 6) == 0) {
		unsigned char bmode;

		ret = sscanf(opt+6, "%x/%d/0x%x", &bmode, &clkrate, &resid);
		if (ret < 1)
			return;
		if (bmode)
			rpt_tmds_cfg2();
		else
			rpt_pixel_cfg2();
	}  else if (strncmp(opt, "test:", 5) == 0)
		hdmi_test_mode(opt + 5);
	else if (strncmp(opt, "secure_reg:", 11) == 0) {
		unsigned int Tx_entry;
		unsigned int Rx_entry;

		ret = sscanf(opt+11, "%x/%x", &Tx_entry, &Rx_entry);
		if (ret < 1)
			return;

		fgCaHDMISetSecureRegEntry(Tx_entry, Rx_entry);
	} else
		goto Error;
	return;

Error:
	HDMI_ATTR_SPRINTF("[HDMI TX]parse command error\n");
}

struct dentry *hdmitx_debugfs;

static int debug_open(struct inode *inode, struct file *file)
{
	file->private_data = inode->i_private;
	return 0;
}

static ssize_t debug_read(struct file *file,
	char __user *ubuf, size_t count, loff_t *ppos)
{
	int n = 0;

	n = strlen(debug_buffer);
	debug_buffer[n++] = 0;

	return simple_read_from_buffer(ubuf, count, ppos, debug_buffer, n);
}

static ssize_t debug_write(struct file *file,
	const char __user *ubuf, size_t count, loff_t *ppos)
{
	// debug_bufmax = 4095 - 1 = 4094;
	const int debug_bufmax = sizeof(debug_buffer) - 1;
	ssize_t ret;

	ret = count;

	// count > 4094, 0~4094
	if (count > debug_bufmax)
		return -EFAULT;

	if (ubuf == NULL)
		return -EFAULT;

	if (copy_from_user(&debug_buffer, ubuf, count))
		return -EFAULT;

	for (int i = 0; i < count; i++)
		if (!isprint(debug_buffer[i]))
			return -EINVAL;

	//max is [4094]
	debug_buffer[count] = 0;
	buf_offset = 0;

	process_dbg_cmd(debug_buffer);

	return ret;
}

static const struct file_operations debug_fops = {
	.read = debug_read,
	.write = debug_write,
	.open = debug_open,
};

int hdmitx_debug_init(void)
{
	TX_DEF_LOG("%s\n", __func__);
	hdmitx_debugfs = debugfs_create_file("hdmitx",
		S_IFREG | 0444, NULL, (void *)0, &debug_fops);

	if (IS_ERR(hdmitx_debugfs))
		return PTR_ERR(hdmitx_debugfs);

	return 0;
}

void hdmitx_debug_uninit(void)
{
	debugfs_remove(hdmitx_debugfs);
}


#endif
