| 1 | // ANALOGIX Company |
|---|
| 2 | // HDMI_TX Demo Firmware on SST |
|---|
| 3 | |
|---|
| 4 | #include "dsthalcommon.h" |
|---|
| 5 | #include "dstddgpio.h" |
|---|
| 6 | #include "dsthalsys.h" |
|---|
| 7 | #include "ANX8560.h" |
|---|
| 8 | |
|---|
| 9 | #include "HDMI_TX_System_Config.h" |
|---|
| 10 | |
|---|
| 11 | #if USE_HDMI_RX |
|---|
| 12 | #include <thdmi_8775.h> |
|---|
| 13 | #endif |
|---|
| 14 | |
|---|
| 15 | DS_BOOL gamut_status = 0; |
|---|
| 16 | BYTE hdmi_tx_new_HW_interface_parameter; |
|---|
| 17 | |
|---|
| 18 | void HDMI_TX_API_Video_Config(BYTE video_id,BYTE input_pixel_rpt_time) |
|---|
| 19 | { |
|---|
| 20 | hdmi_tx_video_timing_id = video_id; |
|---|
| 21 | hdmi_tx_in_pix_rpt = input_pixel_rpt_time; |
|---|
| 22 | HDMI_TX_Set_System_State(HDMI_TX_CONFIG_VIDEO); |
|---|
| 23 | } |
|---|
| 24 | |
|---|
| 25 | void HDMI_TX_API_Packets_Config(BYTE pkt_sel) |
|---|
| 26 | { |
|---|
| 27 | s_hdmi_tx_packet_config.packets_need_config |= pkt_sel; |
|---|
| 28 | } |
|---|
| 29 | |
|---|
| 30 | void HDMI_TX_API_AUD_CHStatus_Config(BYTE MODE,BYTE PCM_MODE,BYTE SW_CPRGT,BYTE NON_PCM, |
|---|
| 31 | BYTE PROF_APP,BYTE CAT_CODE,BYTE CH_NUM,BYTE SOURCE_NUM,BYTE CLK_ACCUR,BYTE Fs) |
|---|
| 32 | { |
|---|
| 33 | //MODE: 0x00 = PCM Audio |
|---|
| 34 | //PCM_MODE: 0x00 = 2 audio channels without pre-emphasis; |
|---|
| 35 | //0x01 = 2 audio channels with 50/15 usec pre-emphasis; |
|---|
| 36 | //SW_CPRGT: 0x00 = copyright is asserted; |
|---|
| 37 | // 0x01 = copyright is not asserted; |
|---|
| 38 | //NON_PCM: 0x00 = Represents linear PCM |
|---|
| 39 | //0x01 = For other purposes |
|---|
| 40 | //PROF_APP: 0x00 = consumer applications; |
|---|
| 41 | // 0x01 = professional applications; |
|---|
| 42 | |
|---|
| 43 | //CAT_CODE: Category code |
|---|
| 44 | //CH_NUM: 0x00 = Do not take into account |
|---|
| 45 | // 0x01 = left channel for stereo channel format |
|---|
| 46 | // 0x02 = right channel for stereo channel format |
|---|
| 47 | //SOURCE_NUM: source number |
|---|
| 48 | // 0x00 = Do not take into account |
|---|
| 49 | // 0x01 = 1; 0x02 = 2; 0x03 = 3 |
|---|
| 50 | //CLK_ACCUR: 0x00 = level II |
|---|
| 51 | // 0x01 = level I |
|---|
| 52 | // 0x02 = level III |
|---|
| 53 | // else reserved; |
|---|
| 54 | |
|---|
| 55 | s_hdmi_tx_audio_config.i2s_config.Channel_status1 = (MODE << 7) | (PCM_MODE << 5) | |
|---|
| 56 | (SW_CPRGT << 2) | (NON_PCM << 1) | PROF_APP; |
|---|
| 57 | s_hdmi_tx_audio_config.i2s_config.Channel_status2 = CAT_CODE; |
|---|
| 58 | s_hdmi_tx_audio_config.i2s_config.Channel_status3 = (CH_NUM << 7) | SOURCE_NUM; |
|---|
| 59 | s_hdmi_tx_audio_config.i2s_config.Channel_status4 = (CLK_ACCUR << 5) | Fs; |
|---|
| 60 | HDMI_TX_DebugPrintf("audio channel status Fs = %.2x\n", (unsigned int)s_hdmi_tx_audio_config.i2s_config.Channel_status4); |
|---|
| 61 | HDMI_TX_Set_System_State(HDMI_TX_CONFIG_AUDIO); |
|---|
| 62 | } |
|---|
| 63 | |
|---|
| 64 | void HDMI_TX_API_AVI_Config(BYTE pb1,BYTE pb2,BYTE pb3,BYTE pb4,BYTE pb5, |
|---|
| 65 | BYTE pb6,BYTE pb7,BYTE pb8,BYTE pb9,BYTE pb10,BYTE pb11,BYTE pb12,BYTE pb13) |
|---|
| 66 | { |
|---|
| 67 | s_hdmi_tx_packet_config.avi_info.pb_byte[1] = pb1; |
|---|
| 68 | s_hdmi_tx_packet_config.avi_info.pb_byte[2] = pb2; |
|---|
| 69 | s_hdmi_tx_packet_config.avi_info.pb_byte[3] = pb3; |
|---|
| 70 | s_hdmi_tx_packet_config.avi_info.pb_byte[4] = pb4; |
|---|
| 71 | s_hdmi_tx_packet_config.avi_info.pb_byte[5] = pb5; |
|---|
| 72 | s_hdmi_tx_packet_config.avi_info.pb_byte[6] = pb6; |
|---|
| 73 | s_hdmi_tx_packet_config.avi_info.pb_byte[7] = pb7; |
|---|
| 74 | s_hdmi_tx_packet_config.avi_info.pb_byte[8] = pb8; |
|---|
| 75 | s_hdmi_tx_packet_config.avi_info.pb_byte[9] = pb9; |
|---|
| 76 | s_hdmi_tx_packet_config.avi_info.pb_byte[10] = pb10; |
|---|
| 77 | s_hdmi_tx_packet_config.avi_info.pb_byte[11] = pb11; |
|---|
| 78 | s_hdmi_tx_packet_config.avi_info.pb_byte[12] = pb12; |
|---|
| 79 | s_hdmi_tx_packet_config.avi_info.pb_byte[13] = pb13; |
|---|
| 80 | } |
|---|
| 81 | |
|---|
| 82 | void HDMI_TX_API_AUD_INFO_Config(BYTE pb1,BYTE pb2,BYTE pb3,BYTE pb4,BYTE pb5, |
|---|
| 83 | BYTE pb6,BYTE pb7,BYTE pb8,BYTE pb9,BYTE pb10) |
|---|
| 84 | { |
|---|
| 85 | s_hdmi_tx_packet_config.audio_info.pb_byte[1] = pb1; |
|---|
| 86 | s_hdmi_tx_packet_config.audio_info.pb_byte[2] = pb2; |
|---|
| 87 | s_hdmi_tx_packet_config.audio_info.pb_byte[3] = pb3; |
|---|
| 88 | s_hdmi_tx_packet_config.audio_info.pb_byte[4] = pb4; |
|---|
| 89 | s_hdmi_tx_packet_config.audio_info.pb_byte[5] = pb5; |
|---|
| 90 | s_hdmi_tx_packet_config.audio_info.pb_byte[6] = pb6; |
|---|
| 91 | s_hdmi_tx_packet_config.audio_info.pb_byte[7] = pb7; |
|---|
| 92 | s_hdmi_tx_packet_config.audio_info.pb_byte[8] = pb8; |
|---|
| 93 | s_hdmi_tx_packet_config.audio_info.pb_byte[9] = pb9; |
|---|
| 94 | s_hdmi_tx_packet_config.audio_info.pb_byte[10] = pb10; |
|---|
| 95 | } |
|---|
| 96 | |
|---|
| 97 | BIT HDMI_TX_API_DetectDevice(void) |
|---|
| 98 | { |
|---|
| 99 | BYTE i; |
|---|
| 100 | BYTE c, d1, d2; |
|---|
| 101 | |
|---|
| 102 | for (i=0; i<10; i++) |
|---|
| 103 | { |
|---|
| 104 | DHL_SYS_SetGPIO(GPIO_HDMI_TX_RESET, 0); |
|---|
| 105 | OS_mDelay(1); |
|---|
| 106 | DHL_SYS_SetGPIO(GPIO_HDMI_TX_RESET, 1); |
|---|
| 107 | OS_mDelay(1); |
|---|
| 108 | |
|---|
| 109 | c = DHL_SYS_ANXRead(0, HDMI_TX_DEV_IDL_REG, &d1); |
|---|
| 110 | if (c != sizeof(d1)) continue; |
|---|
| 111 | |
|---|
| 112 | c = DHL_SYS_ANXRead(0, HDMI_TX_DEV_IDH_REG, &d2); |
|---|
| 113 | if (c != sizeof(d2)) continue; |
|---|
| 114 | |
|---|
| 115 | if (d1 == 0x60 && d2 == 0x85) |
|---|
| 116 | { |
|---|
| 117 | HDMI_TX_DebugPrintf("HDMI_TX detected!\n"); |
|---|
| 118 | return 1; |
|---|
| 119 | } |
|---|
| 120 | |
|---|
| 121 | HDMI_TX_DebugPrintf("device not detected\n"); |
|---|
| 122 | |
|---|
| 123 | return 0; |
|---|
| 124 | } |
|---|
| 125 | |
|---|
| 126 | HDMI_TX_DebugPrintf("device not detected\n"); |
|---|
| 127 | |
|---|
| 128 | return 0; |
|---|
| 129 | } |
|---|
| 130 | |
|---|
| 131 | void HDMI_TX_API_HoldVideoConfig(BIT hold_video) |
|---|
| 132 | { |
|---|
| 133 | hdmi_tx_app_hold_video_config = hold_video; |
|---|
| 134 | } |
|---|
| 135 | |
|---|
| 136 | void HDMI_TX_API_HoldAudioConfig(BIT hold_audio) |
|---|
| 137 | { |
|---|
| 138 | hdmi_tx_app_hold_audio_config = hold_audio; |
|---|
| 139 | } |
|---|
| 140 | |
|---|
| 141 | void HDMI_TX_API_ShutDown(BIT bShutDown_HDMI_TX) |
|---|
| 142 | { |
|---|
| 143 | hdmi_tx_shutdown = bShutDown_HDMI_TX; |
|---|
| 144 | } |
|---|
| 145 | void HDMI_TX_API_SetGamutStatus(DS_BOOL on){ |
|---|
| 146 | |
|---|
| 147 | gamut_status = on; |
|---|
| 148 | |
|---|
| 149 | } |
|---|
| 150 | DS_BOOL HDMI_TX_API_GetGamutStatus(void) |
|---|
| 151 | { |
|---|
| 152 | |
|---|
| 153 | return gamut_status; |
|---|
| 154 | } |
|---|
| 155 | void HDMI_TX_API_HDCP_ONorOFF(BIT HDCP_ONorOFF) |
|---|
| 156 | { |
|---|
| 157 | BIT on; |
|---|
| 158 | on = HDCP_ONorOFF; |
|---|
| 159 | #if 1 |
|---|
| 160 | hdmi_tx_HDCP_enable = HDCP_ONorOFF; |
|---|
| 161 | #else |
|---|
| 162 | hdmi_tx_HDCP_enable = 0;// 1: on; 0:off |
|---|
| 163 | #endif |
|---|
| 164 | } |
|---|
| 165 | |
|---|