⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tlg1100api.h

📁 泰景的模拟电视全部驱动及MTK平台界面代码
💻 H
📖 第 1 页 / 共 5 页
字号:

/** Perform NULL pointer check and return TLG_ERR_PARAM if it fails.
 */
#define TLG_NULLPTR_CHECK(ptr) if (!(ptr)) {TLG_REG_LOG((b,"Bad Ptr\n"));return(TLG_ERR_PARAM);}

/** Perform bounds check and return TLG_ERR_PARAM if it fails.
 */
#define TLG_BOUNDS_CHECK(var, bound) if ((var) > (bound)) {TLG_REG_LOG((b,"bad bounds check %d > %d\n", (var), (bound)));return(TLG_ERR_PARAM);}
#else
#define TLG_NULLPTR_CHECK(ptr)
#define TLG_BOUNDS_CHECK(var, bound)
#endif /* TLG_DO_ERROR_CHECKING */


#ifdef TLG_DO_REG_LOGGING
#include <stdio.h>
/** CUSTOMER SUPPLIED informative logging facility.
 *
 * @fn void TLG_WriteLog(char *str);
 *
 * If TLG_DO_REG_LOGGING is #defined, informative logging will be turned on.
 * The informative logging depends on a function TLG_WriteLog() which must be
 * created in a separate source file and linked into the final application. If
 * TLG_DO_REG_LOGGING is not #defined, this function is not needed.
 * 
 * @param str   Pointer to a character string to be printed to the customer's
 *              logging facility.
 */
void TLG_WriteLog(char *str);

#define TLG_REG_LOG(a) do {char b[200];sprintf a ;TLG_WriteLog(b);} while(0)
#else
#define TLG_REG_LOG(a)
#endif /* TLG_DO_REG_LOGGING */

#ifdef TLG_EMBEDDED_TIMERS
/** CUSTOMER SUPPLIED millisecond delay timer.
 * 
 * @fn TLG_Delay(uint16 milliseconds)
 *
 * This procedure waits the given number of milliseconds before returning to
 * the caller. This function must be created in a separate source file and
 * linked into the final application. 
 * Currently TLG_SetTVChnFreq() TLG_SetFMChnFreq(), TLG_ScanTVChn(), and
 * TLG_ScanFMChn() have embedded calles to TLG_Delay(). If TLG_EMBEDDED_TIMERS
 * is not defined then these procedures will return TLG_ERR_NOT_SUPPORTED and
 * the Asynchronous versions of the procedures must be used.
 *
 * @param milliseconds  The number of milliseconds to wait until return.
 */
void TLG_Delay(uint16 milliseconds);
#else
#define TLG_Delay(a)
#endif /* TLG_EMBEDDED_TIMERS */

/*
 * These defines support the runtime chip version checking feature. 
 */
#ifdef TLG_SUPPORT_RUNTIME_CHECK
extern int g_tlg_chip_ver;
#define TLG_CHIP_VERS_1_3_BEGIN			if (g_tlg_chip_ver >= TLG1100_VERS_1_3) {
#define TLG_CHIP_VERS_1_2_ELSE			} else if (g_tlg_chip_ver >= TLG1100_VERS_1_2) {
#define TLG_CHIP_VERS_1_2_BEGIN			if (g_tlg_chip_ver >= TLG1100_VERS_1_2) {
#define TLG_CHIP_VERS_1_1_ELSE			} else {
#define TLG_CHIP_VERS_ELSE				} else {
#define TLG_CHIP_VERS_END				}
#else
#define TLG_CHIP_VERS_1_3_ELSE	
#define TLG_CHIP_VERS_1_3_BEGIN
#define TLG_CHIP_VERS_1_2_ELSE
#define TLG_CHIP_VERS_1_2_BEGIN
#define TLG_CHIP_VERS_ELSE
#define TLG_CHIP_VERS_1_1_ELSE
#define TLG_CHIP_VERS_END
#endif /* TLG_SUPPORT_RUNTIME_CHECK */


/** Get the current version information for the TLG1100 Portable C Library.
 * 
 * This procedure returns the version number for the TLG1100 Portable C
 * Library. The version is in the form major.minor.patch.
 *
 * @param base_addr         I2c address for TLG1100 chip.
 * @param major             The major version number.
 * @param minor             The minor version number.
 * @param patch             The current patch level.
 *
 * @retval TLG_ERR_SUCCESS          Call succeeded.
 * @retval TLG_ERR_PARAM            Bad parameter value passed.
 * @retval TLG_ERR_FAIL             Error during call.
 */
TLGDLL_API int TLG_GetVersion(uint32 base_addr, uint16 *major, uint16 *minor, uint16 *patch);

/** Get the current version of the TLG1100 chip.
 * 
 * This procedure returns the version number for the TLG1100 FE Chip.
 * The version is in the form major.minor.patch.
 *
 * @param base_addr         I2c address for TLG1100 chip.
 * @param version           Returns the chip revision identifier. Valid values:
 *                          - TLG_NO_VERS
 *                          - TLG1100_VERS_1_1
 *                          - TLG1100_VERS_1_2
 *
 * @retval TLG_ERR_SUCCESS          Call succeeded.
 * @retval TLG_ERR_PARAM            Bad parameter value passed.
 * @retval TLG_ERR_FAIL             Error during call.
 */
TLGDLL_API int TLG_GetChipVersion(uint32 base_addr, uint32 *version);

/** Perform a hard reset of TLG1100.
 * 
 * This procedure performs a hard reset of TLG1100. It should be run if hardware
 * reset (RSTN, Pin-59) fails. This procedure should be called after power-on and
 * before TLG_Init(). 
 *
 * @param base_addr     I2c address for TLG1100 chip
 * 
 * @retval TLG_ERR_SUCCESS          Call succeeded.
 * @retval TLG_ERR_PARAM            Bad parameter value passed.
 * @retval TLG_ERR_NOT_SUPPORTED    Chip version is not supported.
 * @retval TLG_ERR_FAIL             Error during call.
 */
TLGDLL_API int TLG_HardReset(uint32 base_addr);

/** Perform a synchronous initialization of the TLG1100.
 * 
 * This procedure performs initial powerup settings for the TLG1100. See
 * TLG_InitASYNC() for a complete description of powerup procedures. This call
 * embeds the asynchronous nature of TLG_InitASYNC() for those implementations
 * that can handle synchronous calls. NOTE, THIS PROCEDURE RELIES ON
 * TLG_EMBEDDED_TIMERS BEING DEFINED. IF THIS IS NOT DEFINED, THEN THIS
 * PROCEDURE WILL RETURN TLG_ERR_NOT_SUPPORTED AND NO INITIALIZATION WILL BE
 * PERFORMED.
 *
 * @param base_addr     I2c address for TLG1100 chip
 * 
 * @retval TLG_ERR_SUCCESS          Call succeeded.
 * @retval TLG_ERR_PARAM            Bad parameter value passed.
 * @retval TLG_ERR_NOT_SUPPORTED    TLG_EMBEDDED_TIMERS not defined.
 * @retval TLG_ERR_FAIL             Error during call.
 */
TLGDLL_API int TLG_Init(uint32 base_addr);

/** Initialize TLG1100 Asynchronously.
 *
 * This procedure performs initial power-up settings for the TLG1100. Note that
 * for now there are additional register settings in the tlg1100.ini file that
 * comes with the TLG API source. These register settings should be done prior
 * to the call to TLG_InitASYNC(). Also there are some delays required to the
 * startup procedure in TLG_Init() so it is implemented as a state machine. The
 * simple example of how to perform initialization is:
 *
 * Write custom procedure to set registers defined in tlg1100.ini using 
 * TLG_WriteReg().
 *
 * tlg_statep state;
 *
 * int delay;
 *
 * state[0] = TLG_STATE0;
 * 
 * while (state[0] != TLG_STATE_FINAL) {
 *
 *      TLG_InitASYNC(base_address, state, &delay);
 *
 *      if (delay != 0) TLG_Delay(delay);
 *
 * }
 *
 * For implementations that can't put delays in their init code, the calls may
 * be distributed over an event messaging or timer callback service. 
 *
 * @param base_addr     I2c address for TLG1100 chip
 * @param state         State vector. By convention state[0] holds the state
 *                      variable and Initially this should be set to 
 *                      TLG_STATE0. After that it should treated
 *                      as READ ONLY for the remainder of the call. 
 *                      When state[0] == TLG_STATE_FINAL initialization is 
 *                      complete. No more calls to TLG_InitASYNC() are needed.
 * @param ms            Returns the number of minimum number of milliseconds 
 *                      before the next TLG_InitASYNC() call is made.
 * 
 * @retval TLG_ERR_SUCCESS  Call succeeded.
 * @retval TLG_ERR_PARAM    Bad parameter value passed.
 * @retval TLG_ERR_FAIL     Error during call.
 */
TLGDLL_API int TLG_InitASYNC(uint32 base_addr, tlg_statep state, int *ms);

/** Get the current video YUV scaling values.
 *
 * Get the current Y, U, V scaling factors configured into the TLG1100.
 *
 * @param base_addr     I2c address for TLG1100 chip.
 * @param y             Pointer to parameter to fill with the current y scale.
 *                      Valid range: 0-15.
 * @param u             Pointer to parameter to fill with the current u scale.
 *                      Valid range: 0-255.
 * @param v             Pointer to parameter to fill with the current v scale.
 *                      Valid range: 0-255.
 * 
 * @retval TLG_ERR_SUCCESS  Call succeeded.
 * @retval TLG_ERR_PARAM    Bad parameter value passed.
 * @retval TLG_ERR_FAIL     Error during call.
 */
TLGDLL_API int TLG_GetYUVScale(uint32 base_addr, uint16 *y, uint16 *u, uint16 *v);


/** Set the video YUV scaling values.
 *
 * Set the Y, U, and V scaling values to be used by the TLG1100 video output.
 * The settings will take effect immediately.
 *
 * @param base_addr     I2c address for TLG1100 chip.
 * @param y             The new y scale. Valid range: 0-15.
 * @param u             The new u scale. Valid range: 0-255.
 * @param v             The new v scale. Valid range: 0-255.
 * 
 * @retval TLG_ERR_SUCCESS  Call succeeded.
 * @retval TLG_ERR_PARAM    Bad parameter value passed.
 * @retval TLG_ERR_FAIL     Error during call.
 */
TLGDLL_API int TLG_SetYUVScale(uint32 base_addr, uint16 y,uint16 u, uint16 v);

/** Get the current state of the Force Black/White mode.
 *
 * This procedure returns whether the TLG1100 is in "force black and white"
 * mode. Note: this mode doesn't effect test pattern.
 *
 * @param base_addr     I2c address for TLG1100 chip.
 * @param val           Pointer to parameter to fill with the current state.
 *                      Possible values are:
 *                      - TLG_OFF
 *                      - TLG_ON
 * 
 * @retval TLG_ERR_SUCCESS  Call succeeded.
 * @retval TLG_ERR_PARAM    Bad parameter value passed.
 * @retval TLG_ERR_FAIL     Error during call.
 */
TLGDLL_API int TLG_GetBWVideoMode(uint32 base_addr, uint16 *val);

/** Turn off/on the Force Black/White mode.
 *
 * This procedure enables/disables the "force black and white" mode. This is
 * mainly for testing purposes only.
 *
 * @param base_addr     I2c address for TLG1100 chip.
 * @param val           Value to set state to. Possible values:
 *                      - TLG_OFF
 *                      - TLG_ON
 * 
 * @retval TLG_ERR_SUCCESS  Call succeeded.
 * @retval TLG_ERR_PARAM    Bad parameter value passed.
 * @retval TLG_ERR_FAIL     Error during call.
 */
TLGDLL_API int TLG_SetBWVideoMode(uint32 base_addr, uint16 val);

/** Get the current state of the Generate Video Test Pattern mode.
 *
 * This procedure returnes whether the TLG1100 is currently in the "display
 * test pattern" mode. This mode is mainly for testing purposes only.
 *
 * @param base_addr     I2c address for TLG1100 chip.
 * @param val           Pointer to parameter to fill with the current state.
 *                      Possible values are:
 *                      - TLG_OFF
 *                      - TLG_ON
 * 
 * @retval TLG_ERR_SUCCESS  Call succeeded.
 * @retval TLG_ERR_PARAM    Bad parameter value passed.
 * @retval TLG_ERR_FAIL     Error during call.
 */
TLGDLL_API int TLG_GetVideoTestPatternState(uint32 base_addr, uint16 *val);

/** Turn off/on the Generate Video Test Pattern mode.
 *
 * Enable/disable the "display test pattern" mode.
 *
 * @param base_addr     I2c address for TLG1100 chip.
 * @param val           Value to set state to. Possible values:
 *                      - TLG_OFF
 *                      - TLG_ON
 * 
 * @retval TLG_ERR_SUCCESS  Call succeeded.
 * @retval TLG_ERR_PARAM    Bad parameter value passed.
 * @retval TLG_ERR_FAIL     Error during call.
 */
TLGDLL_API int TLG_SetVideoTestPatternState(uint32 base_addr, uint16 val);

/** Get the current state of the 601 Video clock.
 *
 * This procedure gets the current state of the 601 clock mode. Note that by 
 * default the 601 clock is in TLG_INVERT mode.
 *
 * @param base_addr     I2c address for TLG1100 chip.
 * @param val           Pointer to parameter to fill with the current state.
 *                      Possible values are:
 *                      - TLG_NORMAL
 *                      - TLG_INVERT
 * 
 * @retval TLG_ERR_SUCCESS  Call succeeded.
 * @retval TLG_ERR_PARAM    Bad parameter value passed.
 * @retval TLG_ERR_FAIL     Error during call.
 */
TLGDLL_API int TLG_Get601VideoOutClock(uint32 base_addr, uint16 *val);

/** Set the state of the 601 Video clock.
 *
 * This procedure sets the behaviour of the 601 clock. Note that by default
 * the 601 clock is in TLS_INVERT mode. This setting will be enabled 
 * immediately after the call.
 *
 * @param base_addr     I2c address for TLG1100 chip.
 * @param val           Value to set state to. Possible values:
 *                      - TLG_NORMAL
 *                      - TLG_INVERT - default value!
 * 
 * @retval TLG_ERR_SUCCESS  Call succeeded.
 * @retval TLG_ERR_PARAM    Bad parameter value passed.
 * @retval TLG_ERR_FAIL     Error during call.
 */
TLGDLL_API int TLG_Set601VideoOutClock(uint32 base_addr, uint16 val);

/** Get the current order of the Chroma/Luma.
 *
 * This procedure returns the current order of the Chroma/Luma output.
 *
 * @param base_addr     I2c address for TLG1100 chip.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -