| 1 | #include <stdio.h> |
|---|
| 2 | #include <stdarg.h> |
|---|
| 3 | |
|---|
| 4 | #include "dsthalcommon.h" |
|---|
| 5 | |
|---|
| 6 | #include "HDMI_TX_DRV.h" |
|---|
| 7 | #include "HDMI_TX_System_Config.h" |
|---|
| 8 | #include "ANX8560.h" |
|---|
| 9 | |
|---|
| 10 | #if USE_HDMI_RX |
|---|
| 11 | #include <thdmi_8775.h> |
|---|
| 12 | #endif |
|---|
| 13 | |
|---|
| 14 | ///////////////////////////////////////////////////////////////////////////// |
|---|
| 15 | // Local Functions / Variables |
|---|
| 16 | ///////////////////////////////////////////////////////////////////////////// |
|---|
| 17 | static int g_ExistDevice; |
|---|
| 18 | extern int g_SyncLockDelay; |
|---|
| 19 | //typedef void (*CbSyncLockFunc_t)(int, int, int); |
|---|
| 20 | |
|---|
| 21 | const struct Video_Timing Video_Timing_720p[] = { |
|---|
| 22 | {1650, 1280, 750, 720, 147, 40, 183, 5, 5, 20, 0, 0, 0, 1}, /* For 480i */ |
|---|
| 23 | {1650, 1280, 750, 720, 147, 40, 183, 5, 5, 20, 0, 0, 0, 1}, /* For 480p */ |
|---|
| 24 | {1650, 1280, 750, 720, 147, 40, 183, 5, 5, 20, 0, 0, 0, 1}, /* For 720p */ |
|---|
| 25 | {1650, 1280, 749, 722, 147, 40, 183, 5, 5, 20, 0, 0, 0, 1}, /* For 1080i */ |
|---|
| 26 | {1650, 1280, 750, 720, 147, 40, 183, 5, 5, 20, 0, 0, 0, 1}, /* For 1080p */ |
|---|
| 27 | {1650, 1280, 750, 720, 147, 40, 183, 5, 5, 20, 0, 0, 0, 1}, /* For VGA */ |
|---|
| 28 | {1650, 1280, 750, 720, 147, 40, 183, 5, 5, 20, 0, 0, 0, 1}, /* For others */ |
|---|
| 29 | }; |
|---|
| 30 | |
|---|
| 31 | ///////////////////////////////////////////////////////////////////////////// |
|---|
| 32 | // Global Functions / Variables |
|---|
| 33 | ///////////////////////////////////////////////////////////////////////////// |
|---|
| 34 | int g_BIST_OnOff = 0, g_BIST_Resolution = 0, g_BIST_Pattern = 0; |
|---|
| 35 | int g_HDMI_TX_FormatChange = 1; |
|---|
| 36 | void HDMI_TX_SyncLockCallback(int ucMode, int bDTV, int ucSignal, int inVFreq); |
|---|
| 37 | |
|---|
| 38 | ///////////////////////////////////////////////////////////////////////////// |
|---|
| 39 | // Extern Functions / Variables |
|---|
| 40 | ///////////////////////////////////////////////////////////////////////////// |
|---|
| 41 | |
|---|
| 42 | BIT restart_system; |
|---|
| 43 | static int EnableDebug = 0; |
|---|
| 44 | static int g_DelaySyncLock = 0; |
|---|
| 45 | |
|---|
| 46 | int HDMI_TX_Debug(int enable) |
|---|
| 47 | { |
|---|
| 48 | EnableDebug = enable; |
|---|
| 49 | |
|---|
| 50 | return EnableDebug; |
|---|
| 51 | } |
|---|
| 52 | |
|---|
| 53 | int HDMI_TX_DebugPrintf(char const *str, ...) |
|---|
| 54 | { |
|---|
| 55 | int length = 0; |
|---|
| 56 | |
|---|
| 57 | if (EnableDebug == 1) |
|---|
| 58 | { |
|---|
| 59 | va_list v; |
|---|
| 60 | |
|---|
| 61 | va_start(v, str); |
|---|
| 62 | vprintf(str, v); |
|---|
| 63 | } |
|---|
| 64 | |
|---|
| 65 | return length; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | int preset_hdcp = 1; |
|---|
| 69 | |
|---|
| 70 | void HDMI_TX_PreSetHDCP(int value) |
|---|
| 71 | { |
|---|
| 72 | preset_hdcp = value; |
|---|
| 73 | } |
|---|
| 74 | |
|---|
| 75 | void HDMI_TX_SetEXTSwing(int NewExtSwing) |
|---|
| 76 | { |
|---|
| 77 | extern BYTE bExtSwing; |
|---|
| 78 | |
|---|
| 79 | bExtSwing = NewExtSwing; |
|---|
| 80 | if ( HDMI_TX_Get_System_State() >= HDMI_TX_WAIT_HOTPLUG ) { |
|---|
| 81 | if ( NewExtSwing == 1 ) |
|---|
| 82 | DHL_SYS_ANXWrite(0, HDMI_TX_ANA_BLK_CTRL0_REG, HDMI_TX_ANA_BLK_CTRL0_ST_EN | 0x05); // for video blinking problem... |
|---|
| 83 | else |
|---|
| 84 | DHL_SYS_ANXWrite(0, HDMI_TX_ANA_BLK_CTRL0_REG, HDMI_TX_ANA_BLK_CTRL0_ST_EN | 0x01); // for video blinking problem... |
|---|
| 85 | } |
|---|
| 86 | } |
|---|
| 87 | |
|---|
| 88 | int HDMI_TX_Initialize(void) |
|---|
| 89 | { |
|---|
| 90 | int ret = -1; |
|---|
| 91 | |
|---|
| 92 | g_ExistDevice = 0; |
|---|
| 93 | restart_system = 0; |
|---|
| 94 | if (HDMI_TX_API_DetectDevice() == 1) |
|---|
| 95 | { |
|---|
| 96 | HDMI_TX_API_Initial(); |
|---|
| 97 | HDMI_TX_API_ShutDown(0); |
|---|
| 98 | HDMI_TX_API_HDCP_ONorOFF(preset_hdcp); |
|---|
| 99 | // HDMI_TX_API_HoldSystemConfig(0); |
|---|
| 100 | HDMI_TX_Debug(1); |
|---|
| 101 | |
|---|
| 102 | g_ExistDevice = 1; |
|---|
| 103 | ret = 0; |
|---|
| 104 | } |
|---|
| 105 | |
|---|
| 106 | return ret; |
|---|
| 107 | } |
|---|
| 108 | |
|---|
| 109 | int HDMI_TX_IsExistDevice(void) |
|---|
| 110 | { |
|---|
| 111 | return g_ExistDevice; |
|---|
| 112 | } |
|---|
| 113 | |
|---|
| 114 | void HDMI_TX_SetFormatChange(int En) |
|---|
| 115 | { |
|---|
| 116 | g_HDMI_TX_FormatChange = En; |
|---|
| 117 | fprintf(stderr, "|%s, %d| HDMI Tx Format change = %x\n", __FUNCTION__, __LINE__, g_HDMI_TX_FormatChange); |
|---|
| 118 | } |
|---|
| 119 | |
|---|
| 120 | int HDMI_TX_IsFormatChange(void) |
|---|
| 121 | { |
|---|
| 122 | return g_HDMI_TX_FormatChange; |
|---|
| 123 | } |
|---|
| 124 | |
|---|
| 125 | static int lastLockMode = 0; |
|---|
| 126 | static int lastIsDTV = 0; |
|---|
| 127 | static int lastSignal = 0; |
|---|
| 128 | static int lastInVFreq = 60; |
|---|
| 129 | void HDMI_TX_SyncLockCallback(int ucMode, int bDTV, int ucSignal, int inVFreq) |
|---|
| 130 | { |
|---|
| 131 | if ( DHL_CAP_GetSyncLockEnable() == 0 ) |
|---|
| 132 | return; |
|---|
| 133 | |
|---|
| 134 | if ( HDMI_TX_Get_System_State() < HDMI_TX_PLAY_BACK ) |
|---|
| 135 | ucMode = -1; |
|---|
| 136 | |
|---|
| 137 | switch(ucMode) { |
|---|
| 138 | } |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | |
|---|
| 142 | |
|---|
| 143 | int HDMI_TX_MonitorThread(void) |
|---|
| 144 | { |
|---|
| 145 | #define null 0 |
|---|
| 146 | |
|---|
| 147 | if (g_ExistDevice != 1) |
|---|
| 148 | { |
|---|
| 149 | HDMI_TX_DebugPrintf("|%s| LINE=%d, Cannot run monitor thread : anx8560 not found.\n", __FUNCTION__, __LINE__); |
|---|
| 150 | |
|---|
| 151 | return -1; |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | while (1) |
|---|
| 155 | { |
|---|
| 156 | if (restart_system) |
|---|
| 157 | { |
|---|
| 158 | HDMI_TX_DebugPrintf("Restart System...\n"); |
|---|
| 159 | restart_system = 0; |
|---|
| 160 | HDMI_TX_API_Initial(); |
|---|
| 161 | } |
|---|
| 162 | |
|---|
| 163 | if(!hdmi_tx_shutdown) |
|---|
| 164 | { |
|---|
| 165 | if (g_BIST_OnOff == 0) |
|---|
| 166 | { |
|---|
| 167 | HDMI_TX_Task(); |
|---|
| 168 | } |
|---|
| 169 | else |
|---|
| 170 | { |
|---|
| 171 | HDMI_TX_BIST_Task(); |
|---|
| 172 | } |
|---|
| 173 | |
|---|
| 174 | HDMI_TX_SyncLockCallback( lastLockMode, lastIsDTV, lastSignal, lastInVFreq ); |
|---|
| 175 | } |
|---|
| 176 | |
|---|
| 177 | OS_mDelay(300); |
|---|
| 178 | } |
|---|
| 179 | |
|---|
| 180 | return 0; |
|---|
| 181 | } |
|---|
| 182 | |
|---|
| 183 | void HDMI_TX_BIST_OnOff(int onoff) |
|---|
| 184 | { |
|---|
| 185 | g_BIST_OnOff = onoff; |
|---|
| 186 | } |
|---|
| 187 | |
|---|
| 188 | void HDMI_TX_BIST_Resolution(int i) |
|---|
| 189 | { |
|---|
| 190 | g_BIST_Resolution = i; |
|---|
| 191 | } |
|---|
| 192 | |
|---|
| 193 | void HDMI_TX_BIST_Pattern(int i) |
|---|
| 194 | { |
|---|
| 195 | g_BIST_Pattern = i; |
|---|
| 196 | } |
|---|
| 197 | |
|---|
| 198 | void HDMI_TX_EnableMonitorThread(int En) |
|---|
| 199 | { |
|---|
| 200 | hdmi_tx_shutdown = !En; |
|---|
| 201 | } |
|---|
| 202 | |
|---|
| 203 | void HDMI_TX_EnableDelaySynclock(int En) |
|---|
| 204 | { |
|---|
| 205 | printf("DelaySyncLock: %d -> %d\n", g_DelaySyncLock, En ); |
|---|
| 206 | g_DelaySyncLock = En; |
|---|
| 207 | } |
|---|