[processor-sdk/performance-audio-sr.git] / pdk_k2g_1_0_1 / packages / ti / board / diag / hdmi / src / evmk2g_hdmi.h
1 /*
2 * Copyright (c) 2016, Texas Instruments Incorporated
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 */
34 /**
35 *
36 * \file evmk2g_hdmi.h
37 *
38 * \brief This is the header file for hdmi
39 ******************************************************************************/
41 #ifndef _EVMK2G_HDMI_H_
42 #define _EVMK2G_HDMI_H_
44 /**************************************************************************
45 ** Macro Definitions
46 **************************************************************************/
48 /** Macros for I2C slave address and instance */
49 #define HDMI_SLAVE_ADDR (0x3B)
50 #define HDMI_I2C_INSTANCE (1)
52 /** Macros definitons for return types */
53 #define HDMI_ERR (-1)
54 #define HDMI_SUCCESS (0)
56 /** Macros to unmute/mute HDMI audio */
57 #define HDMI_AUDIO_MUTE (1)
58 #define HDMI_AUDIO_UNMUTE (0)
60 /** Macros for HDMI GPIO pin */
61 #define HDMI_ENABLE_GPIO_INSTANCE (0)
62 #define HDMI_ENABLE_GPIO_PIN (84)
63 #define HDMI_INT_GPIO_INSTANCE (1)
64 #define HDMI_INT_GPIO_PIN (31)
66 /** Macro for maximum number of bytes to read edid */
67 #define HDMI_EDID_MAX_LEN (256)
69 /** Registers for HDMI controller */
70 #define HDMI_REG_CHIPID0 (0x1B)
71 #define HDMI_REG_TPI_RQB (0xC7)
73 #define VERTICAL_FREQ (0x3C)
75 /** HDMI TPI Registers */
76 #define HDMI_TPI_VIDEO_DATA_BASE_REG (0x00)
77 #define HDMI_TPI_PIXEL_CLK_LSB_REG (HDMI_TPI_VIDEO_DATA_BASE_REG + 0x00)
78 #define HDMI_TPI_PIXEL_CLK_MSB_REG (HDMI_TPI_VIDEO_DATA_BASE_REG + 0x01)
79 #define HDMI_TPI_VFREQ_LSB_REG (HDMI_TPI_VIDEO_DATA_BASE_REG + 0x02)
80 #define HDMI_TPI_VFREQ_MSB_REG (HDMI_TPI_VIDEO_DATA_BASE_REG + 0x03)
81 #define HDMI_TPI_PIXELS_LSB_REG (HDMI_TPI_VIDEO_DATA_BASE_REG + 0x04)
82 #define HDMI_TPI_PIXELS_MSB_REG (HDMI_TPI_VIDEO_DATA_BASE_REG + 0x05)
83 #define HDMI_TPI_LINES_LSB_REG (HDMI_TPI_VIDEO_DATA_BASE_REG + 0x06)
84 #define HDMI_TPI_LINES_MSB_REG (HDMI_TPI_VIDEO_DATA_BASE_REG + 0x07)
86 #define HDMI_TPI_PIXEL_REPETITION_REG (0x08)
88 #define HDMI_TPI_AVI_INOUT_BASE_REG (0x09)
89 #define HDMI_TPI_AVI_IN_FORMAT_REG (HDMI_TPI_AVI_INOUT_BASE_REG + 0x00)
90 #define HDMI_TPI_AVI_OUT_FORMAT_REG (HDMI_TPI_AVI_INOUT_BASE_REG + 0x01)
92 #define HDMI_SYS_CTRL_DATA_REG (0x1A)
93 #define HDMI_TPI_POWER_STATE_CTRL_REG (0x1E)
95 #define HDMI_REG_1F (0x1F)
96 #define HDMI_REG_20 (0x20)
97 #define HDMI_REG_21 (0x21)
98 #define HDMI_REG_22 (0x22)
99 #define HDMI_REG_23 (0x23)
100 #define HDMI_REG_24 (0x24)
101 #define HDMI_REG_25 (0x25)
102 #define HDMI_REG_26 (0x26)
103 #define HDMI_REG_27 (0x27)
104 #define HDMI_REG_BC (0xBC)
105 #define HDMI_REG_BD (0xBD)
106 #define HDMI_REG_BE (0xBE)
108 /** Macros for HDCP */
109 #define HDMI_TPI_HDCP_QUERYDATA_REG (0x29)
110 #define HDMI_TPI_HDCP_CONTROLDATA_REG (0x2A)
112 /** Macros for HDMI_TPI_AVI_OUTPUT_FORMAT */
113 #define TPI_AVI_OUTPUT_CONV_BT709 (1 << 4)
114 #define TPI_AVI_OUTPUT_CONV_BT601 (0 << 4)
115 #define TPI_AVI_OUTPUT_RANGE_LIMITED (2 << 2)
116 #define TPI_AVI_OUTPUT_RANGE_FULL (1 << 2)
117 #define TPI_AVI_OUTPUT_RANGE_AUTO (0 << 2)
118 #define TPI_AVI_OUTPUT_COLORSPACE_RGBDVI (3 << 0)
119 #define TPI_AVI_OUTPUT_COLORSPACE_YUV422 (2 << 0)
120 #define TPI_AVI_OUTPUT_COLORSPACE_YUV444 (1 << 0)
121 #define TPI_AVI_OUTPUT_COLORSPACE_RGBHDMI (0 << 0)
123 /** Macros for HDMI_SYS_CTRL_DATA_REG */
124 #define TPI_SYS_CTRL_POWER_DOWN (1 << 4)
125 #define TPI_SYS_CTRL_POWER_ACTIVE (0 << 4)
126 #define TPI_SYS_CTRL_AV_MUTE (1 << 3)
127 #define TPI_SYS_CTRL_DDC_BUS_REQUEST (1 << 2)
128 #define TPI_SYS_CTRL_DDC_BUS_GRANTED (1 << 1)
129 #define TPI_SYS_CTRL_OUTPUT_MODE_HDMI (1 << 0)
130 #define TPI_SYS_CTRL_OUTPUT_MODE_DVI (0 << 0)
132 /** Macros for ratio of TDMS Clock to input Video Clock */
133 #define TPI_CLK_RATIO_HALF (0 << 6)
134 #define TPI_CLK_RATIO_1X (1 << 6)
135 #define TPI_CLK_RATIO_2X (2 << 6)
136 #define TPI_CLK_RATIO_4X (3 << 6)
138 /** Macros for HDMI_TPI_DEVICE_POWER_STATE */
139 #define TPI_AVI_POWER_STATE_D3 (3 << 0)
140 #define TPI_AVI_POWER_STATE_D2 (2 << 0)
141 #define TPI_AVI_POWER_STATE_D0 (0 << 0)
143 /** Macros for HDMI_TPI_PIXEL_REPETITION */
144 #define TPI_AVI_PIXEL_REP_BUS_24BIT (1 << 5)
145 #define TPI_AVI_PIXEL_REP_BUS_12BIT (0 << 5)
146 #define TPI_AVI_PIXEL_REP_RISING_EDGE (1 << 4)
147 #define TPI_AVI_PIXEL_REP_FALLING_EDGE (0 << 4)
148 #define TPI_AVI_PIXEL_REP_4X (3 << 0)
149 #define TPI_AVI_PIXEL_REP_2X (1 << 0)
150 #define TPI_AVI_PIXEL_REP_NONE (0 << 0)
152 /** Macros for HDMI_TPI_AVI_INPUT_FORMAT */
153 #define TPI_AVI_INPUT_BITMODE_12BIT (1 << 7)
154 #define TPI_AVI_INPUT_BITMODE_8BIT (0 << 7)
155 #define TPI_AVI_INPUT_DITHER (1 << 6)
156 #define TPI_AVI_INPUT_RANGE_LIMITED (2 << 2)
157 #define TPI_AVI_INPUT_RANGE_FULL (1 << 2)
158 #define TPI_AVI_INPUT_RANGE_AUTO (0 << 2)
159 #define TPI_AVI_INPUT_COLORSPACE_BLACK (3 << 0)
160 #define TPI_AVI_INPUT_COLORSPACE_YUV422 (2 << 0)
161 #define TPI_AVI_INPUT_COLORSPACE_YUV444 (1 << 0)
162 #define TPI_AVI_INPUT_COLORSPACE_RGB (0 << 0)
164 /** Macors for Stream Header Data */
165 #define HDMI_SH_PCM (0x1 << 4)
166 #define HDMI_SH_TWO_CHANNELS (0x1 << 0)
167 #define HDMI_SH_44KHz (0x2 << 2)
168 #define HDMI_SH_48KHz (0x3 << 2)
169 #define HDMI_SH_16BIT (0x1 << 0)
170 #define HDMI_SH_24BIT (0x3 << 0)
171 #define HDMI_SH_SPKR_FLFR (0x0)
172 #define HDMI_SH_0dB_ATUN (0x0)
175 /**************************************************************************
176 ** API function Prototypes
177 **************************************************************************/
179 /**
180 *
181 * \brief Initializes the HDMI controller.
182 *
183 * \param NULL.
184 *
185 * \return NONE.
186 *
187 */
188 int8_t hdmiInit(void);
190 /**
191 *
192 * \brief This function is used to set all the registers to enable
193 * the HDMI transmitter.
194 *
195 * \param NULL.
196 *
197 * \return HDMI_SUCCESS - On Success.
198 * HDMI_ERR - On Failure.
199 *
200 */
201 int8_t hdmiHwEnable(void);
203 /**
204 * \brief Enables the power state of HDMI controller.
205 *
206 * \return HDMI_SUCCESS - On Success
207 * HDMI_ERR - On Failure
208 *
209 */
210 int8_t hdmiConnect(void);
212 /**
213 * \brief Reads the HDMI edid information.
214 *
215 * \param data [IN] Pointer to the data buffer
216 * \param dataLen [IN] Length of edid data to be read.
217 *
218 * \return HDMI_SUCCESS - On Success
219 * HDMI_ERR - On Failure
220 *
221 */
222 int8_t hdmiReadEdid(uint8_t *data, uint32_t dataLen);
224 /**
225 *
226 * \brief This function is used to check the HDMI chip version.
227 *
228 * \param chipVer : Pointer to the buffer passed from test app.
229 *
230 * \return HDMI_SUCCESS - On Success.
231 * HDMI_ERR - On Failure.
232 *
233 */
234 int8_t hdmiProbeChipVersion(uint8_t *chipVer);
236 /**
237 *
238 * \brief Configures HDMI audio
239 *
240 * \param NULL.
241 *
242 * \return HDMI_SUCCESS - On Success
243 * HDMI_ERR - On Failure
244 *
245 */
246 int8_t hdmiAudioConfigure(void);
248 #endif /* _EVMK2G_HDMI_H_ */