+++ /dev/null
-///*****************************************\r
-// Copyright (C) 2009-2014\r
-// ITE Tech. Inc. All Rights Reserved\r
-// Proprietary and Confidential\r
-///*****************************************\r
-// @file <hdmitx_sys.c>\r
-// @author Jau-Chih.Tseng@ite.com.tw\r
-// @date 2012/12/20\r
-// @fileversion: ITE_HDMITX_SAMPLE_3.14\r
-//******************************************/\r
-\r
-///////////////////////////////////////////////////////////////////////////////\r
-// This is the sample program for CAT6611 driver usage.\r
-///////////////////////////////////////////////////////////////////////////////\r
-#include <linux/kernel.h>\r
-#include <linux/delay.h>\r
-\r
-#include "hdmitx.h"\r
-#include "hdmitx_sys.h"\r
-\r
-_CODE HDMITXDEV InstanceData =\r
-{\r
-\r
- 0, // BYTE I2C_DEV ;\r
- HDMI_TX_I2C_SLAVE_ADDR, // BYTE I2C_ADDR ;\r
-\r
- /////////////////////////////////////////////////\r
- // Interrupt Type\r
- /////////////////////////////////////////////////\r
- 0x40, // BYTE bIntType ; // = 0 ;\r
- /////////////////////////////////////////////////\r
- // Video Property\r
- /////////////////////////////////////////////////\r
- INPUT_SIGNAL_TYPE ,// BYTE bInputVideoSignalType ; // for Sync Embedded,CCIR656,InputDDR\r
-\r
- /////////////////////////////////////////////////\r
- // Audio Property\r
- /////////////////////////////////////////////////\r
- I2S_FORMAT, // BYTE bOutputAudioMode ; // = 0 ;\r
- FALSE , // BYTE bAudioChannelSwap ; // = 0 ;\r
- 0x01, // BYTE bAudioChannelEnable ;\r
- INPUT_SAMPLE_FREQ ,// BYTE bAudFs ;\r
- 0, // unsigned long TMDSClock ;\r
- FALSE, // BYTE bAuthenticated:1 ;\r
- FALSE, // BYTE bHDMIMode: 1;\r
- FALSE, // BYTE bIntPOL:1 ; // 0 = Low Active\r
- FALSE, // BYTE bHPD:1 ;\r
-};\r
-\r
-#ifdef HDMITX_INPUT_INFO\r
-// HDMI_VTiming currVTiming ;\r
-////////////////////////////////////////////////////////////////////////////////\r
-// HDMI VTable\r
-////////////////////////////////////////////////////////////////////////////////\r
-static HDMI_VTiming _CODE s_VMTable[] = {\r
-\r
- { 1,0,640,480,800,525,25175000L,0x89,16,96,48,10,2,33,PROG,Vneg,Hneg},//640x480@60Hz\r
- { 2,0,720,480,858,525,27000000L,0x80,16,62,60,9,6,30,PROG,Vneg,Hneg},//720x480@60Hz\r
- { 3,0,720,480,858,525,27000000L,0x80,16,62,60,9,6,30,PROG,Vneg,Hneg},//720x480@60Hz\r
- { 4,0,1280,720,1650,750,74250000L,0x2E,110,40,220,5,5,20,PROG,Vpos,Hpos},//1280x720@60Hz\r
- { 5,0,1920,540,2200,562,74250000L,0x2E,88,44,148,2,5,15,INTERLACE,Vpos,Hpos},//1920x1080(I)@60Hz\r
- { 6,1,720,240,858,262,13500000L,0x100,19,62,57,4,3,15,INTERLACE,Vneg,Hneg},//720x480(I)@60Hz\r
- { 7,1,720,240,858,262,13500000L,0x100,19,62,57,4,3,15,INTERLACE,Vneg,Hneg},//720x480(I)@60Hz\r
- { 8,1,720,240,858,262,13500000L,0x100,19,62,57,4,3,15,PROG,Vneg,Hneg},//720x480(I)@60Hz\r
- { 9,1,720,240,858,262,13500000L,0x100,19,62,57,4,3,15,PROG,Vneg,Hneg},//720x480(I)@60Hz\r
- {10,2,720,240,858,262,54000000L,0x40,19,62,57,4,3,15,INTERLACE,Vneg,Hneg},//720x480(I)@60Hz\r
- {11,2,720,240,858,262,54000000L,0x40,19,62,57,4,3,15,INTERLACE,Vneg,Hneg},//720x480(I)@60Hz\r
- {12,2,720,240,858,262,54000000L,0x40,19,62,57,4,3,15,PROG,Vneg,Hneg},//720x480(I)@60Hz\r
- {13,2,720,240,858,262,54000000L,0x40,19,62,57,4,3,15,PROG,Vneg,Hneg},//720x480(I)@60Hz\r
- {14,1,1440,480,1716,525,54000000L,0x40,32,124,120,9,6,30,PROG,Vneg,Hneg},//1440x480@60Hz\r
- {15,1,1440,480,1716,525,54000000L,0x40,32,124,120,9,6,30,PROG,Vneg,Hneg},//1440x480@60Hz\r
- {16,0,1920,1080,2200,1125,148500000L,0x17,88,44,148,4,5,36,PROG,Vpos,Hpos},//1920x1080@60Hz\r
- {17,0,720,576,864,625,27000000L,0x80,12,64,68,5,5,39,PROG,Vneg,Hneg},//720x576@50Hz\r
- {18,0,720,576,864,625,27000000L,0x80,12,64,68,5,5,39,PROG,Vneg,Hneg},//720x576@50Hz\r
- {19,0,1280,720,1980,750,74250000L,0x2E,440,40,220,5,5,20,PROG,Vpos,Hpos},//1280x720@50Hz\r
- {20,0,1920,540,2640,562,74250000L,0x2E,528,44,148,2,5,15,INTERLACE,Vpos,Hpos},//1920x1080(I)@50Hz\r
- {21,1,720,288,864,312,13500000L,0x100,12,63,69,2,3,19,INTERLACE,Vneg,Hneg},//1440x576(I)@50Hz\r
- {22,1,720,288,864,312,13500000L,0x100,12,63,69,2,3,19,INTERLACE,Vneg,Hneg},//1440x576(I)@50Hz\r
- {23,1,720,288,864,312,13500000L,0x100,12,63,69,2,3,19,PROG,Vneg,Hneg},//1440x288@50Hz\r
- {24,1,720,288,864,312,13500000L,0x100,12,63,69,2,3,19,PROG,Vneg,Hneg},//1440x288@50Hz\r
- {25,2,720,288,864,312,13500000L,0x100,12,63,69,2,3,19,INTERLACE,Vneg,Hneg},//1440x576(I)@50Hz\r
- {26,2,720,288,864,312,13500000L,0x100,12,63,69,2,3,19,INTERLACE,Vneg,Hneg},//1440x576(I)@50Hz\r
- {27,2,720,288,864,312,13500000L,0x100,12,63,69,2,3,19,PROG,Vneg,Hneg},//1440x288@50Hz\r
- {28,2,720,288,864,312,13500000L,0x100,12,63,69,2,3,19,PROG,Vneg,Hneg},//1440x288@50Hz\r
- {29,1,1440,576,1728,625,54000000L,0x40,24,128,136,5,5,39,PROG,Vpos,Hneg},//1440x576@50Hz\r
- {30,1,1440,576,1728,625,54000000L,0x40,24,128,136,5,5,39,PROG,Vpos,Hneg},//1440x576@50Hz\r
- {31,0,1920,1080,2640,1125,148500000L,0x17,528,44,148,4,5,36,PROG,Vpos,Hpos},//1920x1080@50Hz\r
- {32,0,1920,1080,2750,1125,74250000L,0x2E,638,44,148,4,5,36,PROG,Vpos,Hpos},//1920x1080@24Hz\r
- {33,0,1920,1080,2640,1125,74250000L,0x2E,528,44,148,4,5,36,PROG,Vpos,Hpos},//1920x1080@25Hz\r
- {34,0,1920,1080,2200,1125,74250000L,0x2E,88,44,148,4,5,36,PROG,Vpos,Hpos},//1920x1080@30Hz\r
-\r
- {35,2,2880,480,1716*2,525,108000000L,0x20,32*2,124*2,120*2,9,6,30,PROG,Vneg,Hneg},//2880x480@60Hz\r
- {36,2,2880,480,1716*2,525,108000000L,0x20,32*2,124*2,120*2,9,6,30,PROG,Vneg,Hneg},//2880x480@60Hz\r
- {37,1,2880,576,3456,625,108000000L,0x20,24*2,128*2,136*2,5,5,39,PROG,Vneg,Hneg},//2880x576@50Hz\r
- {38,2,2880,576,3456,625,108000000L,0x20,24*2,128*2,136*2,5,5,39,PROG,Vneg,Hneg},//2880x576@50Hz\r
-\r
- {39,0,1920,540,2304,625,72000000L,0x17,32,168,184,23,5,57,INTERLACE,Vneg,Hpos},//1920x1080@50Hz\r
- // 100Hz\r
- {40,0,1920,540,2640,562,148500000L,0x17,528,44,148,2,5,15,INTERLACE,Vpos,Hpos},//1920x1080(I)@100Hz\r
- {41,0,1280,720,1980,750,148500000L,0x17,440,40,220,5,5,20,PROG,Vpos,Hpos},//1280x720@100Hz\r
- {42,0,720,576,864,625, 54000000L,0x40,12,64,68,5,5,39,PROG,Vneg,Hneg},//720x576@100Hz\r
- {43,0,720,576,864,625, 54000000L,0x40,12,64,68,5,5,39,PROG,Vneg,Hneg},//720x576@100Hz\r
- {44,1,720,288,864,312, 27000000L,0x80,12,63,69,2,3,19,INTERLACE,Vneg,Hneg},//1440x576(I)@100Hz\r
- {45,1,720,288,864,312, 27000000L,0x80,12,63,69,2,3,19,INTERLACE,Vneg,Hneg},//1440x576(I)@100Hz\r
- // 120Hz\r
- {46,0,1920,540,2200,562,148500000L,0x17,88,44,148,2,5,15,INTERLACE,Vpos,Hpos},//1920x1080(I)@120Hz\r
- {47,0,1280,720,1650,750,148500000L,0x17,110,40,220,5,5,20,PROG,Vpos,Hpos},//1280x720@120Hz\r
- {48,0, 720,480, 858,525, 54000000L,0x40,16,62,60,9,6,30,PROG,Vneg,Hneg},//720x480@120Hz\r
- {49,0, 720,480, 858,525, 54000000L,0x40,16,62,60,9,6,30,PROG,Vneg,Hneg},//720x480@120Hz\r
- {50,1, 720,240, 858,262, 27000000L,0x80,19,62,57,4,3,15,INTERLACE,Vneg,Hneg},//720x480(I)@120Hz\r
- {51,1, 720,240, 858,262, 27000000L,0x80,19,62,57,4,3,15,INTERLACE,Vneg,Hneg},//720x480(I)@120Hz\r
-\r
- // 200Hz\r
- {52,0,720,576,864,625,108000000L,0x20,12,64,68,5,5,39,PROG,Vneg,Hneg},//720x576@200Hz\r
- {53,0,720,576,864,625,108000000L,0x20,12,64,68,5,5,39,PROG,Vneg,Hneg},//720x576@200Hz\r
- {54,1,720,288,864,312, 54000000L,0x40,12,63,69,2,3,19,INTERLACE,Vneg,Hneg},//1440x576(I)@200Hz\r
- {55,1,720,288,864,312, 54000000L,0x40,12,63,69,2,3,19,INTERLACE,Vneg,Hneg},//1440x576(I)@200Hz\r
- // 240Hz\r
- {56,0,720,480,858,525,108000000L,0x20,16,62,60,9,6,30,PROG,Vneg,Hneg},//720x480@120Hz\r
- {57,0,720,480,858,525,108000000L,0x20,16,62,60,9,6,30,PROG,Vneg,Hneg},//720x480@120Hz\r
- {58,1,720,240,858,262, 54000000L,0x40,19,62,57,4,3,15,INTERLACE,Vneg,Hneg},//720x480(I)@120Hz\r
- {59,1,720,240,858,262, 54000000L,0x40,19,62,57,4,3,15,INTERLACE,Vneg,Hneg},//720x480(I)@120Hz\r
- // 720p low resolution\r
- {60,0,1280, 720,3300, 750, 59400000L,0x3A,1760,40,220,5,5,20,PROG,Vpos,Hpos},//1280x720@24Hz\r
- {61,0,1280, 720,3960, 750, 74250000L,0x2E,2420,40,220,5,5,20,PROG,Vpos,Hpos},//1280x720@25Hz\r
- {62,0,1280, 720,3300, 750, 74250000L,0x2E,1760,40,220,5,5,20,PROG,Vpos,Hpos},//1280x720@30Hz\r
- // 1080p high refresh rate\r
- {63,0,1920,1080,2200,1125,297000000L,0x0B, 88,44,148,4,5,36,PROG,Vpos,Hpos},//1920x1080@120Hz\r
- {64,0,1920,1080,2640,1125,297000000L,0x0B,528,44,148,4,5,36,PROG,Vpos,Hpos},//1920x1080@100Hz\r
- // VESA mode\r
- {0,0,640,350,832,445,31500000L,0x6D,32,64,96,32,3,60,PROG,Vneg,Hpos},// 640x350@85\r
- {0,0,640,400,832,445,31500000L,0x6D,32,64,96,1,3,41,PROG,Vneg,Hneg},// 640x400@85\r
- {0,0,832,624,1152,667,57283000L,0x3C,32,64,224,1,3,39,PROG,Vneg,Hneg},// 832x624@75Hz\r
- {0,0,720,350,900,449,28322000L,0x7A,18,108,54,59,2,38,PROG,Vneg,Hneg},// 720x350@70Hz\r
- {0,0,720,400,900,449,28322000L,0x7A,18,108,54,13,2,34,PROG,Vpos,Hneg},// 720x400@70Hz\r
- {0,0,720,400,936,446,35500000L,0x61,36,72,108,1,3,42,PROG,Vpos,Hneg},// 720x400@85\r
- {0,0,640,480,800,525,25175000L,0x89,16,96,48,10,2,33,PROG,Vneg,Hneg},// 640x480@60\r
- {0,0,640,480,832,520,31500000L,0x6D,24,40,128,9,3,28,PROG,Vneg,Hneg},// 640x480@72\r
- {0,0,640,480,840,500,31500000L,0x6D,16,64,120,1,3,16,PROG,Vneg,Hneg},// 640x480@75\r
- {0,0,640,480,832,509,36000000L,0x60,56,56,80,1,3,25,PROG,Vneg,Hneg},// 640x480@85\r
- {0,0,800,600,1024,625,36000000L,0x60,24,72,128,1,2,22,PROG,Vpos,Hpos},// 800x600@56\r
- {0,0,800,600,1056,628,40000000L,0x56,40,128,88,1,4,23,PROG,Vpos,Hpos},// 800x600@60\r
- {0,0,800,600,1040,666,50000000L,0x45,56,120,64,37,6,23,PROG,Vpos,Hpos},// 800x600@72\r
- {0,0,800,600,1056,625,49500000L,0x45,16,80,160,1,3,21,PROG,Vpos,Hpos},// 800x600@75\r
- {0,0,800,600,1048,631,56250000L,0x3D,32,64,152,1,3,27,PROG,Vpos,Hpos},// 800X600@85\r
- {0,0,848,480,1088,517,33750000L,0x66,16,112,112,6,8,23,PROG,Vpos,Hpos},// 840X480@60\r
- {0,0,1024,384,1264,408,44900000L,0x4C,8,176,56,0,4,20,INTERLACE,Vpos,Hpos},//1024x768(I)@87Hz\r
- {0,0,1024,768,1344,806,65000000L,0x35,24,136,160,3,6,29,PROG,Vneg,Hneg},// 1024x768@60\r
- {0,0,1024,768,1328,806,75000000L,0x2E,24,136,144,3,6,29,PROG,Vneg,Hneg},// 1024x768@70\r
- {0,0,1024,768,1312,800,78750000L,0x2B,16,96,176,1,3,28,PROG,Vpos,Hpos},// 1024x768@75\r
- {0,0,1024,768,1376,808,94500000L,0x24,48,96,208,1,3,36,PROG,Vpos,Hpos},// 1024x768@85\r
- {0,0,1152,864,1600,900,108000000L,0x20,64,128,256,1,3,32,PROG,Vpos,Hpos},// 1152x864@75\r
- {0,0,1280,768,1440,790,68250000L,0x32,48,32,80,3,7,12,PROG,Vneg,Hpos},// 1280x768@60-R\r
- {0,0,1280,768,1664,798,79500000L,0x2B,64,128,192,3,7,20,PROG,Vpos,Hneg},// 1280x768@60\r
- {0,0,1280,768,1696,805,102250000L,0x21,80,128,208,3,7,27,PROG,Vpos,Hneg},// 1280x768@75\r
- {0,0,1280,768,1712,809,117500000L,0x1D,80,136,216,3,7,31,PROG,Vpos,Hneg},// 1280x768@85\r
-\r
- {0,0,1280,800,1440, 823, 71000000L,0x31, 48, 32, 80,3,6,14,PROG,Vpos,Hneg},// 1280x800@60Hz\r
- {0,0,1280,800,1680, 831, 83500000L,0x29, 72,128,200,3,6,22,PROG,Vpos,Hneg},// 1280x800@60Hz\r
- {0,0,1280,800,1696, 838,106500000L,0x20, 80,128,208,3,6,29,PROG,Vpos,Hneg},// 1280x800@75Hz\r
- {0,0,1280,800,1712, 843,122500000L,0x1C, 80,136,216,3,6,34,PROG,Vpos,Hneg},// 1280x800@85Hz\r
-\r
-\r
- {0,0,1280,960,1800,1000,108000000L,0x20,96,112,312,1,3,36,PROG,Vpos,Hpos},// 1280x960@60\r
- {0,0,1280,960,1728,1011,148500000L,0x17,64,160,224,1,3,47,PROG,Vpos,Hpos},// 1280x960@85\r
- {0,0,1280,1024,1688,1066,108000000L,0x20,48,112,248,1,3,38,PROG,Vpos,Hpos},// 1280x1024@60\r
- {0,0,1280,1024,1688,1066,135000000L,0x19,16,144,248,1,3,38,PROG,Vpos,Hpos},// 1280x1024@75\r
- {0,0,1280,1024,1728,1072,157500000L,0x15,64,160,224,1,3,44,PROG,Vpos,Hpos},// 1280X1024@85\r
- {0,0,1360,768,1792,795,85500000L,0x28,64,112,256,3,6,18,PROG,Vpos,Hpos},// 1360X768@60\r
-\r
- {0,0,1366,768,1792,798,85500000L,0x28, 70,143,213,3,3,24,PROG,Vpos,Hpos},// 1366X768@60\r
- {0,0,1366,768,1500,800,72000000L,0x30, 14, 56, 64,1,3,28,PROG,Vpos,Hpos},// 1360X768@60\r
- {0,0,1400,1050,1560,1080,101000000L,0x22,48,32,80,3,4,23,PROG,Vneg,Hpos},// 1400x768@60-R\r
- {0,0,1400,1050,1864,1089,121750000L,0x1C,88,144,232,3,4,32,PROG,Vpos,Hneg},// 1400x768@60\r
- {0,0,1400,1050,1896,1099,156000000L,0x16,104,144,248,3,4,42,PROG,Vpos,Hneg},// 1400x1050@75\r
- {0,0,1400,1050,1912,1105,179500000L,0x13,104,152,256,3,4,48,PROG,Vpos,Hneg},// 1400x1050@85\r
- {0,0,1440,900,1600,926,88750000L,0x26,48,32,80,3,6,17,PROG,Vneg,Hpos},// 1440x900@60-R\r
- {0,0,1440,900,1904,934,106500000L,0x20,80,152,232,3,6,25,PROG,Vpos,Hneg},// 1440x900@60\r
- {0,0,1440,900,1936,942,136750000L,0x19,96,152,248,3,6,33,PROG,Vpos,Hneg},// 1440x900@75\r
- {0,0,1440,900,1952,948,157000000L,0x16,104,152,256,3,6,39,PROG,Vpos,Hneg},// 1440x900@85\r
- {0,0,1600,1200,2160,1250,162000000L,0x15,64,192,304,1,3,46,PROG,Vpos,Hpos},// 1600x1200@60\r
- {0,0,1600,1200,2160,1250,175500000L,0x13,64,192,304,1,3,46,PROG,Vpos,Hpos},// 1600x1200@65\r
- {0,0,1600,1200,2160,1250,189000000L,0x12,64,192,304,1,3,46,PROG,Vpos,Hpos},// 1600x1200@70\r
- {0,0,1600,1200,2160,1250,202500000L,0x11,64,192,304,1,3,46,PROG,Vpos,Hpos},// 1600x1200@75\r
- {0,0,1600,1200,2160,1250,229500000L,0x0F,64,192,304,1,3,46,PROG,Vpos,Hpos},// 1600x1200@85\r
- {0,0,1680,1050,1840,1080,119000000L,0x1D,48,32,80,3,6,21,PROG,Vneg,Hpos},// 1680x1050@60-R\r
- {0,0,1680,1050,2240,1089,146250000L,0x17,104,176,280,3,6,30,PROG,Vpos,Hneg},// 1680x1050@60\r
- {0,0,1680,1050,2272,1099,187000000L,0x12,120,176,296,3,6,40,PROG,Vpos,Hneg},// 1680x1050@75\r
- {0,0,1680,1050,2288,1105,214750000L,0x10,128,176,304,3,6,46,PROG,Vpos,Hneg},// 1680x1050@85\r
- {0,0,1792,1344,2448,1394,204750000L,0x10,128,200,328,1,3,46,PROG,Vpos,Hneg},// 1792x1344@60\r
- {0,0,1792,1344,2456,1417,261000000L,0x0D,96,216,352,1,3,69,PROG,Vpos,Hneg},// 1792x1344@75\r
- {0,0,1856,1392,2528,1439,218250000L,0x0F,96,224,352,1,3,43,PROG,Vpos,Hneg},// 1856x1392@60\r
- {0,0,1856,1392,2560,1500,288000000L,0x0C,128,224,352,1,3,104,PROG,Vpos,Hneg},// 1856x1392@75\r
- {0,0,1920,1200,2080,1235,154000000L,0x16,48,32,80,3,6,26,PROG,Vneg,Hpos},// 1920x1200@60-R\r
- {0,0,1920,1200,2592,1245,193250000L,0x11,136,200,336,3,6,36,PROG,Vpos,Hneg},// 1920x1200@60\r
- {0,0,1920,1200,2608,1255,245250000L,0x0E,136,208,344,3,6,46,PROG,Vpos,Hneg},// 1920x1200@75\r
- {0,0,1920,1200,2624,1262,281250000L,0x0C,144,208,352,3,6,53,PROG,Vpos,Hneg},// 1920x1200@85\r
- {0,0,1920,1440,2600,1500,234000000L,0x0E,128,208,344,1,3,56,PROG,Vpos,Hneg},// 1920x1440@60\r
- {0,0,1920,1440,2640,1500,297000000L,0x0B,144,224,352,1,3,56,PROG,Vpos,Hneg},// 1920x1440@75\r
-};\r
-#define SizeofVMTable (sizeof(s_VMTable)/sizeof(HDMI_VTiming))\r
-\r
-void HDMITX_MonitorInputVideoChange();\r
-void HDMITX_MonitorInputAudioChange();\r
-\r
-#else\r
-#define SizeofVMTable 0\r
-#endif\r
-\r
-#define DIFF(a,b) (((a)>(b))?((a)-(b)):((b)-(a)))\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// EDID\r
-////////////////////////////////////////////////////////////////////////////////\r
-static _XDATA RX_CAP RxCapability ;\r
-static BOOL bChangeMode = FALSE ;\r
-static BOOL bChangeAudio = FALSE ;\r
-\r
-_XDATA unsigned char CommunBuff[128] ;\r
-// _XDATA AVI_InfoFrame AviInfo;\r
-// _XDATA Audio_InfoFrame AudioInfo ;\r
-// _XDATA VendorSpecific_InfoFrame VS_Info;\r
-_CODE BYTE CA[] = { 0,0,0, 02, 0x3, 0x7, 0xB, 0xF, 0x1F } ;\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Program utility.\r
-////////////////////////////////////////////////////////////////////////////////\r
-\r
-\r
-BYTE bInputColorMode = INPUT_COLOR_MODE;\r
-BYTE OutputColorDepth = INPUT_COLOR_DEPTH ;\r
-BYTE bOutputColorMode = OUTPUT_COLOR_MODE ;\r
-\r
-BYTE iVideoModeSelect=0 ;\r
-\r
-ULONG VideoPixelClock ;\r
-BYTE VIC ; // 480p60\r
-BYTE pixelrep ; // no pixelrepeating\r
-HDMI_Aspec aspec ;\r
-HDMI_Colorimetry Colorimetry ;\r
-\r
-ULONG ulAudioSampleFS = INPUT_SAMPLE_FREQ_HZ ;\r
-// BYTE bAudioSampleFreq = INPUT_SAMPLE_FREQ ;\r
-BYTE bOutputAudioChannel = OUTPUT_CHANNEL ;\r
-\r
-BOOL bHDMIMode;\r
-BYTE bAudioEnable ;\r
-BYTE HPDStatus = FALSE;\r
-BYTE HPDChangeStatus = FALSE;\r
-BYTE bOutputAudioType=CNOFIG_INPUT_AUDIO_TYPE;\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Function Prototype.\r
-////////////////////////////////////////////////////////////////////////////////\r
-BYTE ParseEDID();\r
-static BOOL ParseCEAEDID(BYTE *pCEAEDID);\r
-void ConfigAVIInfoFrame(BYTE VIC, BYTE pixelrep);\r
-void ConfigAudioInfoFrm();\r
-void Config_GeneralPurpose_Infoframe(BYTE *p3DInfoFrame);\r
-void ConfigfHdmiVendorSpecificInfoFrame(BYTE _3D_Stru);\r
-void InitHDMITX_Variable();\r
-void HDMITX_ChangeDisplayOption(HDMI_Video_Type VideoMode, HDMI_OutputColorMode OutputColorMode);\r
-void HDMITX_SetOutput();\r
-int HDMITX_DevLoopProc();\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Function Body.\r
-////////////////////////////////////////////////////////////////////////////////\r
-\r
-void InitHDMITX_Variable()\r
-{\r
- printk( "[%s]\n", __FUNCTION__);\r
- HDMITX_InitTxDev(&InstanceData);\r
- HPDStatus = FALSE;\r
- HPDChangeStatus = FALSE;\r
-}\r
-\r
-BOOL AudioModeDetect(void)\r
-{\r
- setHDMITX_AudioChannelEnable(bAudioEnable);\r
- return TRUE;\r
-}\r
-\r
-void HDMITX_ChangeColorDepth(BYTE colorDepth)\r
-{\r
-#ifdef IT6615\r
- HDMITX_DEBUG_PRINTF(("OHDMITX_ChangeColorDepth(%02X)\n",(int)colorDepth)) ;\r
- OutputColorDepth = colorDepth ;\r
-#else\r
- OutputColorDepth = 0 ;\r
-#endif\r
-}\r
-\r
-void HDMITX_SetOutput()\r
-{\r
- VIDEOPCLKLEVEL level ;\r
- unsigned long TMDSClock = VideoPixelClock*(pixelrep+1);\r
- HDMITX_DisableAudioOutput();\r
- HDMITX_EnableHDCP(FALSE);\r
-\r
- if( TMDSClock>80000000L )\r
- {\r
- level = PCLK_HIGH ;\r
- }\r
- else if(TMDSClock>20000000L)\r
- {\r
- level = PCLK_MEDIUM ;\r
- }\r
- else\r
- {\r
- level = PCLK_LOW ;\r
- }\r
-#ifdef IT6615\r
- HDMITX_DEBUG_PRINTF(("OutputColorDepth = %02X\n",(int)OutputColorDepth)) ;\r
- setHDMITX_ColorDepthPhase(OutputColorDepth,0);\r
-#endif\r
-\r
- setHDMITX_VideoSignalType(InstanceData.bInputVideoSignalType);\r
- #ifdef SUPPORT_SYNCEMBEDDED\r
- if(InstanceData.bInputVideoSignalType & T_MODE_SYNCEMB)\r
- {\r
- setHDMITX_SyncEmbeddedByVIC(VIC,InstanceData.bInputVideoSignalType);\r
- }\r
- #endif\r
-\r
- HDMITX_DEBUG_PRINTF(("level = %d, ,bInputColorMode=%x,bOutputColorMode=%x,bHDMIMode=%x\n",(int)level,(int)bInputColorMode,(int)bOutputColorMode ,(int)bHDMIMode)) ;\r
- HDMITX_EnableVideoOutput(level,bInputColorMode,bOutputColorMode ,bHDMIMode);\r
-\r
- if( bHDMIMode )\r
- {\r
- #ifdef OUTPUT_3D_MODE\r
- ConfigfHdmiVendorSpecificInfoFrame(OUTPUT_3D_MODE);\r
- #endif\r
- //HDMITX_EnableHDCP(TRUE);\r
- ConfigAVIInfoFrame(VIC, pixelrep);\r
-\r
- HDMITX_SetAudioOutput();\r
-\r
- // if( bAudioEnable )\r
- // {\r
- // ConfigAudioInfoFrm();\r
- // #ifdef SUPPORT_HBR_AUDIO\r
- // HDMITX_EnableAudioOutput(T_AUDIO_HBR, CONFIG_INPUT_AUDIO_SPDIF, 768000L,8,NULL,TMDSClock);\r
- // #else\r
- // // HDMITX_EnableAudioOutput(T_AUDIO_LPCM, FALSE, ulAudioSampleFS,OUTPUT_CHANNEL,NULL,TMDSClock);\r
- // HDMITX_EnableAudioOutput(CNOFIG_INPUT_AUDIO_TYPE, CONFIG_INPUT_AUDIO_SPDIF, ulAudioSampleFS,bOutputAudioChannel,NULL,TMDSClock);\r
- // #endif\r
- // }\r
-\r
- }\r
- else\r
- {\r
- HDMITX_EnableAVIInfoFrame(FALSE ,NULL);\r
- HDMITX_EnableVSInfoFrame(FALSE,NULL);\r
- }\r
- setHDMITX_AVMute(FALSE);\r
- bChangeMode = FALSE ;\r
- DumpHDMITXReg() ;\r
-}\r
-\r
-void HDMITX_ChangeAudioOption(BYTE Option, BYTE channelNum, BYTE AudioFs)\r
-{\r
-\r
- switch(Option )\r
- {\r
- case T_AUDIO_HBR :\r
- bOutputAudioType = T_AUDIO_HBR ;\r
- ulAudioSampleFS = 768000L ;\r
- bOutputAudioChannel = 8 ;\r
- return ;\r
- case T_AUDIO_NLPCM :\r
- bOutputAudioType = T_AUDIO_NLPCM ;\r
- bOutputAudioChannel = 2 ;\r
- break ;\r
- default:\r
- bOutputAudioType = T_AUDIO_LPCM ;\r
- if( channelNum < 1 )\r
- {\r
- bOutputAudioChannel = 1 ;\r
- }\r
- else if( channelNum > 8 )\r
- {\r
- bOutputAudioChannel = 8 ;\r
- }\r
- else\r
- {\r
- bOutputAudioChannel = channelNum ;\r
- }\r
- break ;\r
- }\r
-\r
- switch(AudioFs)\r
- {\r
- case AUDFS_44p1KHz:\r
- ulAudioSampleFS = 44100L ;\r
- break ;\r
- case AUDFS_88p2KHz:\r
- ulAudioSampleFS = 88200L ;\r
- break ;\r
- case AUDFS_176p4KHz:\r
- ulAudioSampleFS = 176400L ;\r
- break ;\r
-\r
- case AUDFS_48KHz:\r
- ulAudioSampleFS = 48000L ;\r
- break ;\r
- case AUDFS_96KHz:\r
- ulAudioSampleFS = 96000L ;\r
- break ;\r
- case AUDFS_192KHz:\r
- ulAudioSampleFS = 192000L ;\r
- break ;\r
-\r
- case AUDFS_768KHz:\r
- ulAudioSampleFS = 768000L ;\r
- break ;\r
-\r
- case AUDFS_32KHz:\r
- ulAudioSampleFS = 32000L ;\r
- break ;\r
- default:\r
- ulAudioSampleFS = 48000L ;\r
- break ;\r
- }\r
- HDMITX_DEBUG_PRINTF(("HDMITX_ChangeAudioOption():bOutputAudioType = %02X, ulAudioSampleFS = %8ld, bOutputAudioChannel = %d\n",(int)bOutputAudioType,ulAudioSampleFS,(int)bOutputAudioChannel)) ;\r
- bChangeAudio = TRUE ;\r
-}\r
-\r
-void HDMITX_SetAudioOutput()\r
-{\r
- if( bAudioEnable )\r
- {\r
- ConfigAudioInfoFrm();\r
- // HDMITX_EnableAudioOutput(T_AUDIO_LPCM, FALSE, ulAudioSampleFS,OUTPUT_CHANNEL,NULL,TMDSClock);\r
- HDMITX_EnableAudioOutput(\r
- //CNOFIG_INPUT_AUDIO_TYPE,\r
- bOutputAudioType,\r
- CONFIG_INPUT_AUDIO_SPDIF,\r
- ulAudioSampleFS,\r
- bOutputAudioChannel,\r
- NULL, // pointer to cahnnel status.\r
- VideoPixelClock*(pixelrep+1));\r
- // if you have channel status , set here.\r
- // setHDMITX_ChStat(BYTE ucIEC60958ChStat[]);\r
- bChangeAudio = FALSE ;\r
- }\r
-}\r
-\r
-int HDMITX_DevLoopProc()\r
-{\r
- static BYTE DevLoopCount = 0 ;\r
- CheckHDMITX(&HPDStatus,&HPDChangeStatus);\r
-\r
- if( HPDChangeStatus )\r
- {\r
- if( HPDStatus )\r
- {\r
- HDMITX_PowerOn();\r
- ParseEDID();\r
- bOutputColorMode = F_MODE_RGB444;\r
-\r
- if( RxCapability.ValidHDMI )\r
- {\r
- bHDMIMode = TRUE ;\r
- bAudioEnable = TRUE ;\r
-#if 0\r
- if(RxCapability.VideoMode & (1<<6))\r
- {\r
- bAudioEnable = TRUE ;\r
- }\r
-#endif\r
- if( RxCapability.VideoMode & (1<<5))\r
- {\r
- bOutputColorMode &= ~F_MODE_CLRMOD_MASK ;\r
- bOutputColorMode |= F_MODE_YUV444;\r
- }\r
- else if (RxCapability.VideoMode & (1<<4))\r
- {\r
- bOutputColorMode &= ~F_MODE_CLRMOD_MASK ;\r
- bOutputColorMode |= F_MODE_YUV422 ;\r
- }\r
- bOutputColorMode = F_MODE_RGB444;\r
-\r
-\r
- #ifdef IT6615\r
- if(RxCapability.dc.uc & (HDMI_DC_SUPPORT_36|HDMI_DC_SUPPORT_30))\r
- {\r
- setHDMITX_ColorDepthPhase(OutputColorDepth,0);\r
- }\r
- else\r
- {\r
- OutputColorDepth = B_TX_CD_NODEF;\r
- }\r
- #else\r
- OutputColorDepth = B_TX_CD_NODEF;\r
- #endif\r
- }\r
- else\r
- {\r
- bHDMIMode = FALSE ;\r
- bAudioEnable = FALSE ;\r
- OutputColorDepth = B_TX_CD_NODEF;\r
- // HDMITX_DisableAudioOutput();\r
- // HDMITX_DisableVideoOutput();\r
- #ifdef SUPPORT_HDCP\r
- HDMITX_EnableHDCP(FALSE);\r
- #endif\r
- }\r
- HDMITX_DEBUG_PRINTF(("HPD change HDMITX_SetOutput();\n"));\r
- //HDMITX_SetOutput();\r
- bChangeMode=TRUE;\r
- bChangeAudio = TRUE ;\r
- }\r
- else\r
- {\r
- // unplug mode, ...\r
- HDMITX_DEBUG_PRINTF(("HPD OFF HDMITX_DisableVideoOutput()\n"));\r
- HDMITX_DisableVideoOutput();\r
- HDMITX_PowerDown();\r
- bChangeAudio = FALSE ;\r
- }\r
- }\r
- else // no stable but need to process mode change procedure\r
- {\r
- if( DevLoopCount >= 20 )\r
- {\r
- DevLoopCount = 0 ;\r
- }\r
-\r
- #ifdef HDMITX_AUTO_MONITOR_INPUT\r
- if( DevLoopCount == 0 )\r
- {\r
- HDMITX_MonitorInputVideoChange();\r
- HDMITX_MonitorInputAudioChange();\r
- }\r
- #endif\r
-\r
- if(HPDStatus)\r
- {\r
- #ifdef HDMITX_AUTO_MONITOR_INPUT\r
- if( bChangeMode && ( VIC > 0 ) )\r
- #else\r
- if( bChangeMode )\r
- #endif\r
- {\r
- HDMITX_DEBUG_PRINTF(("Mode change HDMITX_SetOutput();\n"));\r
- HDMITX_SetOutput();\r
- // HDMITX_EnableHDCP(TRUE);\r
-\r
- bChangeMode = FALSE ;\r
- }\r
- if(getHDMITX_LinkStatus())\r
- {\r
- // AudioModeDetect();\r
- #ifdef SUPPORT_HDCP\r
- if(getHDMITX_AuthenticationDone() ==FALSE)\r
- {\r
- HDMITX_DEBUG_PRINTF(("getHDMITX_AuthenticationDone() ==FALSE\n") );\r
- HDMITX_EnableHDCP(TRUE);\r
- setHDMITX_AVMute(FALSE);\r
- }\r
- #endif\r
- }\r
-\r
- if(bChangeAudio)\r
- {\r
- HDMITX_SetAudioOutput() ;\r
- }\r
- }\r
- }\r
-\r
- DevLoopCount ++ ;\r
- return HPDChangeStatus;\r
-}\r
-\r
-#ifdef HDMITX_AUTO_MONITOR_INPUT\r
-\r
-void HDMITX_MonitorInputAudioChange()\r
-{\r
- static ULONG prevAudioSampleFS = 0 ;\r
- LONG AudioFS ;\r
-\r
- if( !bAudioEnable )\r
- {\r
- prevAudioSampleFS = 0 ;\r
- }\r
- else\r
- {\r
- AudioFS = CalcAudFS() ;\r
- HDMITX_DEBUG_PRINTF1(("Audio Chagne, Audio clock = %ldHz\n",AudioFS)) ;\r
- if( AudioFS > 188000L ) // 192KHz\r
- {\r
- ulAudioSampleFS = 192000L ;\r
- }\r
- else if( AudioFS > 144000L ) // 176.4KHz\r
- {\r
- ulAudioSampleFS = 176400L ;\r
- }\r
- else if( AudioFS > 93000L ) // 96KHz\r
- {\r
- ulAudioSampleFS = 96000L ;\r
- }\r
- else if( AudioFS > 80000L ) // 88.2KHz\r
- {\r
- ulAudioSampleFS = 88200L ;\r
- }\r
- else if( AudioFS > 45000L ) // 48 KHz\r
- {\r
- ulAudioSampleFS = 48000L ;\r
- }\r
- else if( AudioFS > 36000L ) // 44.1KHz\r
- {\r
- ulAudioSampleFS = 44100L ;\r
- }\r
- else // 32KHz\r
- {\r
- ulAudioSampleFS = 32000L ;\r
- }\r
-\r
- if(!bChangeMode)\r
- {\r
- if( ulAudioSampleFS != prevAudioSampleFS )\r
- {\r
- HDMITX_DEBUG_PRINTF(("ulAudioSampleFS = %ldHz -> %ldHz\n",ulAudioSampleFS,ulAudioSampleFS)) ;\r
- ConfigAudioInfoFrm();\r
- HDMITX_EnableAudioOutput(CNOFIG_INPUT_AUDIO_TYPE, CONFIG_INPUT_AUDIO_SPDIF, ulAudioSampleFS,OUTPUT_CHANNEL,NULL,0);\r
- // HDMITX_EnableAudioOutput(T_AUDIO_LPCM, FALSE, ulAudioSampleFS,OUTPUT_CHANNEL,NULL,0);\r
-\r
- }\r
- }\r
-\r
- prevAudioSampleFS = ulAudioSampleFS ;\r
-\r
- }\r
-}\r
-\r
-int HDMITX_SearchVICIndex( ULONG PCLK, USHORT HTotal, USHORT VTotal, BYTE ScanMode )\r
-{\r
- #define SEARCH_COUNT 4\r
- unsigned long pclkDiff;\r
- int i;\r
- char hit;\r
- int iMax[SEARCH_COUNT]={0};\r
- char hitMax[SEARCH_COUNT]={0};\r
- char i2;\r
-\r
- for( i = 0 ; i < SizeofVMTable; i++ )\r
- {\r
- if( s_VMTable[i].VIC == 0 ) break ;\r
-\r
- hit=0;\r
-\r
- if( ScanMode == s_VMTable[i].ScanMode )\r
- {\r
- hit++;\r
-\r
- if( ScanMode == INTERLACE )\r
- {\r
- if( DIFF(VTotal/2, s_VMTable[i].VTotal) < 10 )\r
- {\r
- hit++;\r
- }\r
- }\r
- else\r
- {\r
- if( DIFF(VTotal, s_VMTable[i].VTotal) < 10 )\r
- {\r
- hit++;\r
- }\r
- }\r
-\r
- if( hit == 2 ) // match scan mode and v-total\r
- {\r
- if( DIFF(HTotal, s_VMTable[i].HTotal) < 40 )\r
- {\r
- hit++;\r
-\r
- pclkDiff = DIFF(PCLK, s_VMTable[i].PCLK);\r
- pclkDiff = (pclkDiff * 100) / s_VMTable[i].PCLK;\r
-\r
- if( pclkDiff < 100 )\r
- {\r
- hit += ( 100 - pclkDiff );\r
- }\r
- }\r
- }\r
- }\r
-\r
- HDMITX_DEBUG_PRINTF(("i = %d, hit = %d\n",i,(int)hit));\r
-\r
- if( hit )\r
- {\r
- for( i2=0 ; i2<SEARCH_COUNT ; i2++ )\r
- {\r
- if( hitMax[i2] < hit )\r
- {\r
- HDMITX_DEBUG_PRINTF(("replace iMax[%d] = %d => %d\n",(int)i2, iMax[i2], i ));\r
- hitMax[i2] = hit;\r
- iMax[i2]=i;\r
- break;\r
- }\r
- }\r
- }\r
- }\r
-\r
- i=-1;\r
- hit=0;\r
- for( i2=0 ; i2<SEARCH_COUNT ; i2++ )\r
- {\r
- HDMITX_DEBUG_PRINTF(("[%d] i = %d, hit = %d\n",(int)i2, iMax[i2],(int)hitMax[i2]));\r
- if( hitMax[i2] > hit )\r
- {\r
- hit = hitMax[i2];\r
- i = iMax[i2];\r
- }\r
- }\r
-\r
- if( hit > 2 )\r
- {\r
- HDMITX_DEBUG_PRINTF(("i = %d, hit = %d\n",i,(int)hit));\r
- HDMITX_DEBUG_PRINTF((">> mode : %d %u x %u @%lu (%s)\n", (int)s_VMTable[i].VIC, s_VMTable[i].HActive, s_VMTable[i].VActive, s_VMTable[i].PCLK, (s_VMTable[i].ScanMode==0)?"i":"p" ));\r
- }\r
- else\r
- {\r
- i=-1;\r
- HDMITX_DEBUG_PRINTF(("no matched\n"));\r
- }\r
-\r
- return i;\r
-}\r
-\r
-void HDMITX_MonitorInputVideoChange()\r
-{\r
- static ULONG prevPCLK = 0 ;\r
- static USHORT prevHTotal = 0 ;\r
- static USHORT prevVTotal = 0 ;\r
- static BYTE prevScanMode ;\r
- ULONG currPCLK ;\r
- ULONG diff ;\r
- USHORT currHTotal, currVTotal ;\r
- BYTE currScanMode ;\r
- int i ;\r
-\r
- currPCLK = CalcPCLK() ;\r
- currHTotal = hdmitx_getInputHTotal() ;\r
- currVTotal = hdmitx_getInputVTotal() ;\r
- currScanMode = hdmitx_isInputInterlace() ? INTERLACE:PROG ;\r
- diff = DIFF(currPCLK,prevPCLK);\r
-\r
- HDMITX_DEBUG_PRINTF(("HDMITX_MonitorInputVideoChange : pclk=%lu, ht=%u, vt=%u, dif=%lu\n", currPCLK, currHTotal, currVTotal, diff ));\r
-\r
- if( currHTotal == 0 || currVTotal == 0 || currPCLK == 0 )\r
- {\r
- bChangeMode = FALSE;\r
- return ;\r
- }\r
-\r
- if( diff > currPCLK/20) // 5% torrenlance\r
- {\r
- bChangeMode = TRUE ;\r
- }\r
- else\r
- {\r
- diff = DIFF(currHTotal, prevHTotal) ;\r
- if( diff > 20 )\r
- {\r
- bChangeMode = TRUE ;\r
- }\r
- diff = DIFF(currVTotal, prevVTotal) ;\r
- if( diff > 20 )\r
- {\r
- bChangeMode = TRUE ;\r
- }\r
- }\r
-\r
- if( bChangeMode )\r
- {\r
- HDMITX_DEBUG_PRINTF(("PCLK = %ld -> %ld\n",prevPCLK, currPCLK));\r
- HDMITX_DEBUG_PRINTF(("HTotal = %d -> %d\n",prevHTotal, currHTotal));\r
- HDMITX_DEBUG_PRINTF(("VTotal = %d -> %d\n",prevVTotal, currVTotal));\r
- HDMITX_DEBUG_PRINTF(("ScanMode = %s -> %s\n",prevScanMode?"P":"I", currScanMode?"P":"I"));\r
-\r
- HDMITX_DEBUG_PRINTF(("PCLK = %ld,(%dx%d) %s %s\n",currPCLK, currHTotal,currVTotal, (currScanMode==INTERLACE)?"INTERLACED":"PROGRESS",bChangeMode?"CHANGE MODE":"NO CHANGE MODE"));\r
-\r
- setHDMITX_AVMute(TRUE);\r
-\r
- #if 0\r
- for( i = 0 ; (i < SizeofVMTable) && ( s_VMTable[i].VIC != 0 ); i++ )\r
- {\r
- if( s_VMTable[i].VIC == 0 ) break ;\r
- if( DIFF(currPCLK, s_VMTable[i].PCLK) > (s_VMTable[i].PCLK/20))\r
- {\r
- continue ;\r
- }\r
- if( DIFF(currHTotal, s_VMTable[i].HTotal) > 40 )\r
- {\r
- continue ;\r
- }\r
- if( currScanMode != s_VMTable[i].ScanMode )\r
- {\r
- continue ;\r
- }\r
- if( currScanMode == INTERLACE )\r
- {\r
- if( DIFF(currVTotal/2, s_VMTable[i].VTotal) > 10 )\r
- {\r
- continue ;\r
- }\r
- }\r
- else\r
- {\r
- if( DIFF(currVTotal, s_VMTable[i].VTotal) > 10 )\r
- {\r
- continue ;\r
- }\r
- }\r
- printf("i = %d, VIC = %d\n",i,(int)s_VMTable[i].VIC) ;\r
-\r
- break ;\r
- }\r
- #else\r
- i = HDMITX_SearchVICIndex( currPCLK, currHTotal, currVTotal, currScanMode );\r
- #endif\r
-\r
- if( i >= 0 )\r
- {\r
- VIC = s_VMTable[i].VIC;\r
- pixelrep = s_VMTable[i].PixelRep ;\r
- VideoPixelClock = currPCLK ;\r
- }\r
- else\r
- {\r
- VIC = 0;\r
- pixelrep = 0;\r
- VideoPixelClock = 0 ;\r
- }\r
- }\r
-\r
- prevPCLK = currPCLK ;\r
- prevHTotal = currHTotal ;\r
- prevVTotal = currVTotal ;\r
- prevScanMode = currScanMode ;\r
-\r
-}\r
-#endif // HDMITX_AUTO_MONITOR_INPUT\r
-\r
-void HDMITX_ChangeDisplayOption(HDMI_Video_Type OutputVideoTiming, HDMI_OutputColorMode OutputColorMode)\r
-{\r
- printk( "[%s] Vic=%d\n", __FUNCTION__,OutputVideoTiming);\r
- //HDMI_Video_Type t=HDMI_480i60_16x9;\r
- if((F_MODE_RGB444)==(bOutputColorMode&F_MODE_CLRMOD_MASK))//Force output RGB in RGB only case\r
- {\r
- OutputColorMode=F_MODE_RGB444;\r
- }\r
- else if ((F_MODE_YUV422)==(bOutputColorMode&F_MODE_CLRMOD_MASK))//YUV422 only\r
- {\r
- if(OutputColorMode==HDMI_YUV444){OutputColorMode=F_MODE_YUV422;}\r
- }\r
- else if ((F_MODE_YUV444)==(bOutputColorMode&F_MODE_CLRMOD_MASK))//YUV444 only\r
- {\r
- if(OutputColorMode==HDMI_YUV422){OutputColorMode=F_MODE_YUV444;}\r
- }\r
- switch(OutputVideoTiming)\r
- {\r
- case HDMI_640x480p60:\r
- VIC = 1 ;\r
- VideoPixelClock = 25000000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_4x3 ;\r
- Colorimetry = HDMI_ITU601 ;\r
- break ;\r
- case HDMI_480p60:\r
- VIC = 2 ;\r
- VideoPixelClock = 27000000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_4x3 ;\r
- Colorimetry = HDMI_ITU601 ;\r
- break ;\r
- case HDMI_480p60_16x9:\r
- VIC = 3 ;\r
- VideoPixelClock = 27000000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU601 ;\r
- break ;\r
- case HDMI_720p60:\r
- VIC = 4 ;\r
- VideoPixelClock = 74250000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU709 ;\r
- break ;\r
- case HDMI_1080i60:\r
- VIC = 5 ;\r
- VideoPixelClock = 74250000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU709 ;\r
- break ;\r
- case HDMI_480i60:\r
- VIC = 6 ;\r
- VideoPixelClock = 13500000 ;\r
- pixelrep = 1 ;\r
- aspec = HDMI_4x3 ;\r
- Colorimetry = HDMI_ITU601 ;\r
- break ;\r
- case HDMI_480i60_16x9:\r
- VIC = 7 ;\r
- VideoPixelClock = 13500000 ;\r
- pixelrep = 1 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU601 ;\r
- break ;\r
- case HDMI_1080p60:\r
- VIC = 16 ;\r
- VideoPixelClock = 148500000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU709 ;\r
- break ;\r
- case HDMI_576p50:\r
- VIC = 17 ;\r
- VideoPixelClock = 27000000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_4x3 ;\r
- Colorimetry = HDMI_ITU601 ;\r
- break ;\r
- case HDMI_576p50_16x9:\r
- VIC = 18 ;\r
- VideoPixelClock = 27000000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU601 ;\r
- break ;\r
- case HDMI_720p50:\r
- VIC = 19 ;\r
- VideoPixelClock = 74250000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU709 ;\r
- break ;\r
- case HDMI_1080i50:\r
- VIC = 20 ;\r
- VideoPixelClock = 74250000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU709 ;\r
- break ;\r
- case HDMI_576i50:\r
- VIC = 21 ;\r
- VideoPixelClock = 13500000 ;\r
- pixelrep = 1 ;\r
- aspec = HDMI_4x3 ;\r
- Colorimetry = HDMI_ITU601 ;\r
- break ;\r
- case HDMI_576i50_16x9:\r
- VIC = 22 ;\r
- VideoPixelClock = 13500000 ;\r
- pixelrep = 1 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU601 ;\r
- break ;\r
- case HDMI_1080p50:\r
- VIC = 31 ;\r
- VideoPixelClock = 148500000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU709 ;\r
- break ;\r
- case HDMI_1080p24:\r
- VIC = 32 ;\r
- VideoPixelClock = 74250000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU709 ;\r
- break ;\r
- case HDMI_1080p25:\r
- VIC = 33 ;\r
- VideoPixelClock = 74250000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU709 ;\r
- break ;\r
- case HDMI_1080p30:\r
- VIC = 34 ;\r
- VideoPixelClock = 74250000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU709 ;\r
- break ;\r
-\r
- case HDMI_720p30:\r
- VIC = 0 ;\r
- VideoPixelClock = 74250000 ;\r
- pixelrep = 0 ;\r
- aspec = HDMI_16x9 ;\r
- Colorimetry = HDMI_ITU709 ;\r
-\r
- #ifdef SUPPORT_SYNCEMBEDDED\r
- /*\r
- VTiming.HActive=1280 ;\r
- VTiming.VActive=720 ;\r
- VTiming.HTotal=3300 ;\r
- VTiming.VTotal=750 ;\r
- VTiming.PCLK=VideoPixelClock ;\r
- VTiming.xCnt=0x2E ;\r
- VTiming.HFrontPorch= 1760;\r
- VTiming.HSyncWidth= 40 ;\r
- VTiming.HBackPorch= 220 ;\r
- VTiming.VFrontPorch= 5;\r
- VTiming.VSyncWidth= 5 ;\r
- VTiming.VBackPorch= 20 ;\r
- VTiming.ScanMode=PROG ;\r
- VTiming.VPolarity=Vneg ;\r
- VTiming.HPolarity=Hneg ;\r
- */\r
- #endif\r
- break ;\r
- default:\r
- bChangeMode = FALSE ;\r
- return ;\r
- }\r
- switch(OutputColorMode)\r
- {\r
- case HDMI_YUV444:\r
- bOutputColorMode = F_MODE_YUV444 ;\r
- break ;\r
- case HDMI_YUV422:\r
- bOutputColorMode = F_MODE_YUV422 ;\r
- break ;\r
- case HDMI_RGB444:\r
- default:\r
- bOutputColorMode = F_MODE_RGB444 ;\r
- break ;\r
- }\r
- if( Colorimetry == HDMI_ITU709 )\r
- {\r
- bInputColorMode |= F_VIDMODE_ITU709 ;\r
- }\r
- else\r
- {\r
- bInputColorMode &= ~F_VIDMODE_ITU709 ;\r
- }\r
- // if( Colorimetry != HDMI_640x480p60)\r
- if( OutputVideoTiming != HDMI_640x480p60)\r
- {\r
- bInputColorMode |= F_VIDMODE_16_235 ;\r
- }\r
- else\r
- {\r
- bInputColorMode &= ~F_VIDMODE_16_235 ;\r
- }\r
- bChangeMode = TRUE ;\r
-}\r
-\r
-void ConfigAVIInfoFrame(BYTE VIC, BYTE pixelrep)\r
-{\r
- AVI_InfoFrame *AviInfo;\r
- AviInfo = (AVI_InfoFrame *)CommunBuff ;\r
-\r
- AviInfo->pktbyte.AVI_HB[0] = AVI_INFOFRAME_TYPE|0x80 ;\r
- AviInfo->pktbyte.AVI_HB[1] = AVI_INFOFRAME_VER ;\r
- AviInfo->pktbyte.AVI_HB[2] = AVI_INFOFRAME_LEN ;\r
-\r
- switch(bOutputColorMode)\r
- {\r
- case F_MODE_YUV444:\r
- // AviInfo->info.ColorMode = 2 ;\r
- AviInfo->pktbyte.AVI_DB[0] = (2<<5)|(1<<4);\r
- break ;\r
- case F_MODE_YUV422:\r
- // AviInfo->info.ColorMode = 1 ;\r
- AviInfo->pktbyte.AVI_DB[0] = (1<<5)|(1<<4);\r
- break ;\r
- case F_MODE_RGB444:\r
- default:\r
- // AviInfo->info.ColorMode = 0 ;\r
- AviInfo->pktbyte.AVI_DB[0] = (0<<5)|(1<<4);\r
- break ;\r
- }\r
- AviInfo->pktbyte.AVI_DB[1] = 8 ;\r
- AviInfo->pktbyte.AVI_DB[1] |= (aspec != HDMI_16x9)?(1<<4):(2<<4); // 4:3 or 16:9\r
- AviInfo->pktbyte.AVI_DB[1] |= (Colorimetry != HDMI_ITU709)?(1<<6):(2<<6); // 4:3 or 16:9\r
- AviInfo->pktbyte.AVI_DB[2] = 0 ;\r
- AviInfo->pktbyte.AVI_DB[3] = VIC ;\r
- AviInfo->pktbyte.AVI_DB[4] = pixelrep & 3 ;\r
- AviInfo->pktbyte.AVI_DB[5] = 0 ;\r
- AviInfo->pktbyte.AVI_DB[6] = 0 ;\r
- AviInfo->pktbyte.AVI_DB[7] = 0 ;\r
- AviInfo->pktbyte.AVI_DB[8] = 0 ;\r
- AviInfo->pktbyte.AVI_DB[9] = 0 ;\r
- AviInfo->pktbyte.AVI_DB[10] = 0 ;\r
- AviInfo->pktbyte.AVI_DB[11] = 0 ;\r
- AviInfo->pktbyte.AVI_DB[12] = 0 ;\r
-\r
- HDMITX_EnableAVIInfoFrame(TRUE, (unsigned char *)AviInfo);\r
-}\r
-\r
-////////////////////////////////////////////////////////////////////////////////\r
-// Function: ConfigAudioInfoFrm\r
-// Parameter: NumChannel, number from 1 to 8\r
-// Return: ER_SUCCESS for successfull.\r
-// Remark: Evaluate. The speakerplacement is only for reference.\r
-// For production, the caller of hdmitx_SetAudioInfoFrame should program\r
-// Speaker placement by actual status.\r
-// Side-Effect:\r
-////////////////////////////////////////////////////////////////////////////////\r
-\r
-void ConfigAudioInfoFrm()\r
-{\r
- int i ;\r
-\r
- Audio_InfoFrame *AudioInfo ;\r
- AudioInfo = (Audio_InfoFrame *)CommunBuff ;\r
-\r
- HDMITX_DEBUG_PRINTF(("ConfigAudioInfoFrm(%d)\n",2));\r
-\r
- AudioInfo->pktbyte.AUD_HB[0] = AUDIO_INFOFRAME_TYPE ;\r
- AudioInfo->pktbyte.AUD_HB[1] = 1 ;\r
- AudioInfo->pktbyte.AUD_HB[2] = AUDIO_INFOFRAME_LEN ;\r
- AudioInfo->pktbyte.AUD_DB[0] = 1 ;\r
- for( i = 1 ;i < AUDIO_INFOFRAME_LEN ; i++ )\r
- {\r
- AudioInfo->pktbyte.AUD_DB[i] = 0 ;\r
- }\r
- HDMITX_EnableAudioInfoFrame(TRUE, (unsigned char *)AudioInfo);\r
-}\r
-\r
-void ConfigfHdmiVendorSpecificInfoFrame(BYTE _3D_Stru)\r
-{\r
- VendorSpecific_InfoFrame *VS_Info;\r
-\r
- VS_Info=(VendorSpecific_InfoFrame *)CommunBuff ;\r
-\r
- VS_Info->pktbyte.VS_HB[0] = VENDORSPEC_INFOFRAME_TYPE|0x80;\r
- VS_Info->pktbyte.VS_HB[1] = VENDORSPEC_INFOFRAME_VER;\r
- VS_Info->pktbyte.VS_HB[2] = (_3D_Stru == Side_by_Side)?6:5;\r
- VS_Info->pktbyte.VS_DB[0] = 0x03;\r
- VS_Info->pktbyte.VS_DB[1] = 0x0C;\r
- VS_Info->pktbyte.VS_DB[2] = 0x00;\r
- VS_Info->pktbyte.VS_DB[3] = 0x40;\r
- switch(_3D_Stru)\r
- {\r
- case Side_by_Side:\r
- case Frame_Pcaking:\r
- case Top_and_Botton:\r
- VS_Info->pktbyte.VS_DB[4] = (_3D_Stru<<4);\r
- break;\r
- default:\r
- VS_Info->pktbyte.VS_DB[4] = (Frame_Pcaking<<4);\r
- break ;\r
- }\r
- VS_Info->pktbyte.VS_DB[5] = 0x00;\r
- HDMITX_EnableVSInfoFrame(TRUE,(BYTE *)VS_Info);\r
-}\r
-\r
-/////////////////////////////////////////////////////////////////////\r
-// ParseEDID()\r
-// Check EDID check sum and EDID 1.3 extended segment.\r
-/////////////////////////////////////////////////////////////////////\r
-\r
-BYTE ParseEDID()\r
-{\r
- // collect the EDID ucdata of segment 0\r
- _XDATA unsigned char *EDID_Buf;\r
- BYTE CheckSum ;\r
- BYTE BlockCount ;\r
- BYTE err ;\r
- BYTE bValidCEA = FALSE ;\r
- BYTE i;\r
- #if Debug_message\r
- BYTE j ;\r
- #endif // Debug_message\r
-\r
- EDID_Buf = CommunBuff;\r
- RxCapability.ValidCEA = FALSE ;\r
- RxCapability.ValidHDMI = TRUE;\r
- RxCapability.dc.uc = 0;\r
-\r
- getHDMITX_EDIDBlock(0, EDID_Buf);\r
-#if Debug_message\r
- for( j = 0 ; j < 128 ; j++ )\r
- {\r
- EDID_DEBUG_PRINTF(("%02X%c",(int)EDID_Buf[j],(7 == (j&7))?'\n':' '));\r
- }\r
-#endif // Debug_message\r
-\r
- for( i = 0, CheckSum = 0 ; i < 128 ; i++ )\r
- {\r
- CheckSum += EDID_Buf[i] ; CheckSum &= 0xFF ;\r
- }\r
- //Eep_Write(0x80, 0x80, EDID_Buf);\r
- if( CheckSum != 0 )\r
- {\r
- return FALSE ;\r
- }\r
- if( EDID_Buf[0] != 0x00 ||\r
- EDID_Buf[1] != 0xFF ||\r
- EDID_Buf[2] != 0xFF ||\r
- EDID_Buf[3] != 0xFF ||\r
- EDID_Buf[4] != 0xFF ||\r
- EDID_Buf[5] != 0xFF ||\r
- EDID_Buf[6] != 0xFF ||\r
- EDID_Buf[7] != 0x00)\r
- {\r
- return FALSE ;\r
- }\r
- /*\r
- for( i = 0 ; i < 128 ; i++ )\r
- {\r
- HDMITX_DEBUG_PRINTF(("%02X%c",(int)EDID_Buf[i],(7 == (i&7))?'\n':' '));\r
- }\r
- */\r
-\r
- BlockCount = EDID_Buf[0x7E] ;\r
-\r
- if( BlockCount == 0 )\r
- {\r
- return TRUE ; // do nothing.\r
- }\r
- else if ( BlockCount > 4 )\r
- {\r
- BlockCount = 4 ;\r
- }\r
- // read all segment for test\r
- for( i = 1 ; i <= BlockCount ; i++ )\r
- {\r
- err = getHDMITX_EDIDBlock(i, EDID_Buf);\r
-\r
- #if Debug_message\r
- for( j = 0 ; j < 128 ; j++ )\r
- {\r
- EDID_DEBUG_PRINTF(("%02X%c",(int)EDID_Buf[j],(7 == (j&7))?'\n':' '));\r
- }\r
- #endif // Debug_message\r
-\r
- if( err )\r
- {\r
- if( !bValidCEA && EDID_Buf[0] == 0x2 && EDID_Buf[1] == 0x3 )\r
- {\r
- err = ParseCEAEDID(EDID_Buf);\r
- EDID_DEBUG_PRINTF(("err = %s\n",err?"SUCCESS":"FAIL"));\r
- if( err )\r
- {\r
- EDID_DEBUG_PRINTF(("RxCapability.IEEEOUI = %lx\n",RxCapability.IEEEOUI));\r
-\r
- if(RxCapability.IEEEOUI==0x0c03)\r
- {\r
- RxCapability.ValidHDMI = TRUE ;\r
- bValidCEA = TRUE ;\r
- }\r
- else\r
- {\r
- RxCapability.ValidHDMI = FALSE ;\r
- }\r
- }\r
- }\r
- }\r
- }\r
- return err ;\r
-}\r
-\r
-static BOOL ParseCEAEDID(BYTE *pCEAEDID)\r
-{\r
- BYTE offset,End ;\r
- BYTE count ;\r
- BYTE tag ;\r
- int i ;\r
-\r
- if( pCEAEDID[0] != 0x02 || pCEAEDID[1] != 0x03 ) return FALSE ; // not a CEA BLOCK.\r
- End = pCEAEDID[2] ; // CEA description.\r
-\r
- RxCapability.VDOMode[0] = 0x00 ;\r
- RxCapability.VDOMode[1] = 0x00 ;\r
- RxCapability.VDOMode[2] = 0x00 ;\r
- RxCapability.VDOMode[3] = 0x00 ;\r
- RxCapability.VDOMode[4] = 0x00 ;\r
- RxCapability.VDOMode[5] = 0x00 ;\r
- RxCapability.VDOMode[6] = 0x00 ;\r
- RxCapability.VDOMode[7] = 0x00 ;\r
- RxCapability.PA[0] = 0x00 ;\r
- RxCapability.PA[1] = 0x00 ;\r
-\r
- RxCapability.VideoMode = pCEAEDID[3] ;\r
-\r
- RxCapability.NativeVDOMode = 0xff ;\r
-\r
- for( offset = 4 ; offset < End ; )\r
- {\r
- tag = pCEAEDID[offset] >> 5 ;\r
- count = pCEAEDID[offset] & 0x1f ;\r
- switch( tag )\r
- {\r
- case 0x01: // Audio Data Block ;\r
- RxCapability.AUDDesCount = count/3 ;\r
- EDID_DEBUG_PRINTF(("RxCapability.AUDDesCount = %d\n",(int)RxCapability.AUDDesCount));\r
- offset++ ;\r
- for( i = 0 ; i < RxCapability.AUDDesCount && i < MAX_AUDDES_COUNT ; i++ )\r
- {\r
- RxCapability.AUDDes[i].uc[0] = pCEAEDID[offset+i*3] ;\r
- RxCapability.AUDDes[i].uc[1] = pCEAEDID[offset+i*3+1] ;\r
- RxCapability.AUDDes[i].uc[2] = pCEAEDID[offset+i*3+2] ;\r
- }\r
- offset += count ;\r
- break ;\r
-\r
- case 0x02: // Video Data Block ;\r
- offset ++ ;\r
- for( i = 0,RxCapability.NativeVDOMode = 0xff ; i < count ; i++)\r
- {\r
- BYTE VIC ;\r
- VIC = pCEAEDID[offset+i] & (~0x80);\r
- // if( FindModeTableEntryByVIC(VIC) != -1 )\r
- if(VIC<64)\r
- {\r
- RxCapability.VDOMode[VIC/8] |= (1<<(VIC%8));\r
- EDID_DEBUG_PRINTF(("VIC = %d, RxCapability.VDOMode[%d]=%02X\n",(int)VIC,(int)VIC/8,(int)RxCapability.VDOMode[VIC/8] ));\r
- if(( pCEAEDID[offset+i] & 0x80 )&&(RxCapability.NativeVDOMode==0xFF))\r
- {\r
- RxCapability.NativeVDOMode = VIC ;\r
- EDID_DEBUG_PRINTF(("native = %d\n",RxCapability.NativeVDOMode));\r
- }\r
- }\r
- }\r
- offset += count ;\r
- break ;\r
-\r
- case 0x03: // Vendor Specific Data Block ;\r
- offset ++ ;\r
- RxCapability.IEEEOUI = (ULONG)pCEAEDID[offset+2] ;\r
- RxCapability.IEEEOUI <<= 8 ;\r
- RxCapability.IEEEOUI += (ULONG)pCEAEDID[offset+1] ;\r
- RxCapability.IEEEOUI <<= 8 ;\r
- RxCapability.IEEEOUI += (ULONG)pCEAEDID[offset] ;\r
- EDID_DEBUG_PRINTF(("IEEEOUI = %02X %02X %02X %lx",(int)pCEAEDID[offset+2],(int)pCEAEDID[offset+1],(int)pCEAEDID[offset],RxCapability.IEEEOUI));\r
- if( RxCapability.IEEEOUI== 0x0C03)\r
- {\r
- BYTE nextoffset ;\r
- RxCapability.PA[0] = pCEAEDID[offset+3] ;\r
- RxCapability.PA[1] = pCEAEDID[offset+4] ;\r
- if(count>5)\r
- {\r
- RxCapability.dc.uc = pCEAEDID[offset+5]&0x70;\r
- }\r
- if(count>6)\r
- {\r
- RxCapability.MaxTMDSClock = pCEAEDID[offset+6];\r
- }\r
- if(count>7)\r
- {\r
- nextoffset = 8 ;\r
- if(pCEAEDID[offset+7] & 0x80) { nextoffset += 2 ; } // latency\r
- if(pCEAEDID[offset+7] & 0x40) { nextoffset += 2 ; } // interlace latency\r
- if(pCEAEDID[offset+7] & 0x20) {\r
- EDID_DEBUG_PRINTF(("next offset = %d",(int)nextoffset));\r
- RxCapability.Valid3D = (pCEAEDID[offset+nextoffset] & 0x80)?TRUE:FALSE ;\r
- } // interlace latency\r
-\r
- }\r
- }\r
- offset += count ; // ignore the remaind.\r
-\r
- break ;\r
-\r
- case 0x04: // Speaker Data Block ;\r
- offset ++ ;\r
- RxCapability.SpeakerAllocBlk.uc[0] = pCEAEDID[offset] ;\r
- RxCapability.SpeakerAllocBlk.uc[1] = pCEAEDID[offset+1] ;\r
- RxCapability.SpeakerAllocBlk.uc[2] = pCEAEDID[offset+2] ;\r
- offset += 3 ;\r
- break ;\r
- case 0x05: // VESA Data Block ;\r
- offset += count+1 ;\r
- break ;\r
- case 0x07: // Extended Data Block ;\r
- offset += count+1 ; //ignore\r
- break ;\r
- default:\r
- offset += count+1 ; // ignore\r
- }\r
- }\r
- RxCapability.ValidCEA = TRUE ;\r
- return TRUE ;\r
-}\r