123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631 |
- #ifndef _ADC_H_
- #define _ADC_H_
- /**
- * @brief Update gain and offset values on RGB channels.
- *
- * This function gets current gain and offset values on RGB channels separately,
- * and then updates the input structure.
- *
- * @param pstConfig structure for saving gain and offset values.
- *
- */
- extern void DRV_ADC_GetAutoColorValue(ADCCalibrate_OSDGainOffset_t* pstConfig);
- /**
- * @brief Initialize requested input source, and enable/disable power, timer and workqueue.
- *
- * This function would initialize or clear selected input source, including ADC module power,
- * timer function execution and workqueue procedure.
- *
- * @param ucSubInputSource Requested input source type.
- * @param bEnable Enable selected source.
- *
- */
- extern void ADC_SourceSelect(UINT8 ucSubInputSource, BOOL bEnable);
- /**
- * @brief Execute auto adjust for current signal.
- *
- * This function processes phase detection and image centering for input signals.
- * Phase would be set as recorded info directly if bEnable is FALSE. There are several
- * types of centering mode,
- * ucMode = 0, indicate only Hstart and Vstart could be tuned for PC source.
- * ucMode = 1, indicate Hstart, Vstart, Hactive and Vactive could be tuned for PC source.
- * ucMode = 2, indicate Hstart, Vstart, Hactive and Vactive could be tuned for PC, Ypp and Scart_RGB.
- *
- * @param ucPath Not mention in the function.
- * @param bEnable Enable for running phase detection.
- * @param ucMode Image centering mode type.
- *
- */
- extern BOOL ADC_DoAuto(UINT8 ucPath, BOOL bEnable, UINT8 ucMode);
- /**
- * @brief Return -1.
- *
- * This function always retunrs -1.
- *
- * @param ucFunID Not mention in the function
- * @return Always return -1
- *
- */
- extern INT32 ADC_InfoGet(UINT8 ucFunID);
- /**
- * @brief Empty function.
- *
- * This function is empty now.
- *
- * @param ucFunID Not mention in the function
- * @param iValue Not mention in the function
- *
- */
- extern void ADC_InfoSet(UINT8 ucFunID, INT32 iValue);
- //kernel 2.6.35.9 update
- //void __exit DRV_ADC_Linuxexit(void);
- //INT32 __init DRV_ADC_Linuxinit(void);
- //INT32 ADC_Resume(void);
- //INT32 ADC_Suspend(pm_message_t state);
- //ssize_t adc_ioctl(struct inode *inode,struct file *file,UINT32 cmd,ULONG arg);
- /**
- * @brief Notify ADC standby.
- *
- * This function sets ADC flag to indicate the state is standby mode, which should ignore debounce mechanism of VGA plug ISR.
- *
- */
- void ADC_Standby(void);
- void ADC_WakeUp(void);
- /**
- * @brief Enable ADI reset on VIP module.
- *
- * This function requests VIP module to enable ADI reset.
- *
- */
- void ADC_ResetADI_Unlock(void);
- /**
- * @brief Process interrupt status.
- *
- * This function deals with several types of interrupt situations.
- *
- */
- void ADC_InterruptHandler (void);
- /**
- * @brief Search the best gain values for RGB channels.
- *
- * This function sets gains several times, and select one having the least delta
- * value after comparing with specific target.
- *
- * @param bAutoGainMode Whether to reload original lcg settings after gain searching.
- *
- */
- void ADC_SearchGain(BOOL bAutoGainMode);
- /**
- * @brief Disable interrupt and timer before exit ADC module.
- *
- * This function is one of module exit step. It disables interrupt, stops timer
- * and turns off related power.
- *
- */
- void ADC_Close(void);
- /**
- * @brief Setup flags for the first time search gains when initialize ADC module.
- *
- * This function is one of module initialization step. It enables flags related
- * to the first time gain search.
- *
- */
- void ADC_Open(void);
- /**
- * @brief Reset SOG for timer signal off.
- *
- * This function resets SOG when timer signal status is off.
- *
- */
- void ADC_TimerWork(void *unuse);
- /**
- * @brief Find one best phase with the least difference of frame comparison.
- *
- * This function requests VIP module to do frame comparison for each phase, and
- * records these pixel difference values. After collecting all results of frame
- * comparisons, the phase having the least difference value would be chosen as the
- * best phase.
- *
- * @return The best phase number.
- *
- */
- UINT8 ADC_FullPhaseDetected(void);
- /**
- * @brief Process image display centering.
- *
- * This function decides whether to trigger VIP centering function.
- *
- * @param bDoCentering Whether to triger VIP centering or not.
- *
- */
- void ADC_Centering(BOOL bDoCentering);
- /**
- * @brief Set VIP flags and send to VIP.
- *
- * This function sets VIP flags and then calls VIP function to send these information.
- */
- void ADC_SendInfo( void );
- /**
- * @brief Initialize setting according to current source type.
- *
- * This function sets basic settings for initializing current source type.
- *
- */
- void ADC_SourceInit(void);
- /**
- * @brief Timing mode setup.
- *
- * This function setup timing mode in sequential peocedures, including SOG status,
- * timing support and PLL setting.
- *
- * @return Setup timing mode result.
- * @retval VIP_No_Signal indicate SOG is not stable
- * @retval Unsupported_Timing indicate there is no matching timing in table list.
- * @retval Mode_Change_Again indicate HV sync status is unstable.
- * @retval Mode_Change_Stable indicate timing mode is found and signal is stable.
- *
- */
- UINT8 ADC_Mode_Setup( void );
- /**
- * @brief Check SOG stable status.
- *
- * This function checks SOG status for several loops.
- *
- * @return Status of SOG stability.
- *
- */
- BOOL ADC_Signal_Status(void);
- /**
- * @brief Setup timing mode according to referenced timing table.
- *
- * This function loads related timing table settings and adjust SOG or
- * clamping in specific condition.
- *
- */
- void ADC_ModeSetting(void);
- /**
- * @brief Check mode stable status.
- *
- * This function checks mode stable status for several times.
- *
- * @return Whether current mode is stable or not.
- *
- */
- BOOL ADC_ModeStable(void);
- /**
- * @brief Get timing information about HV frequency, vertical count and HV width.
- *
- * This function gets Horizontal/Vertical frequency, vertical count and horizontal/vertical
- * width according to current signals. It cannot execute succesfully until there are specific
- * number of stability count within constrain loops.
- *
- * @param ucStableCnt Continuous stability times for confirming.
- * @param ucTimeOut Total times for checking stability loop.
- * @param ucMdelay Not mention in the function.
- * @return Indicate whther the exts information is got or not.
- *
- */
- BOOL ADC_GetExtsInfo(UINT8 ucStableCnt, UINT8 ucTimeOut, UINT8 ucMdelay);
- /**
- * @brief Check HV sync stable status.
- *
- * This function gets Horizontal/Vertical sync stable status according to requesting VIP.
- *
- * @param ucTimeOut Polling times for requesting VIP in the first round.
- * @return Sync stable status.
- *
- */
- BOOL ADC_CheckSyncStable(UINT8 ucTimeOut);
- /**
- * @brief Print message about loaded timing table.
- *
- * This function prints debugging message related to loaded timing table,
- * and always returns FALSE.
- *
- * @return Timing table loading status.
- *
- */
- BOOL ADC_CheckLoadTableValueRange(void);
- /**
- * @brief Load information of Vesa timing structure for YPP.
- *
- * This function update Vesa timing structure of YPP according to computation result of
- * related horizontal and vertical factors.
- *
- * @param ucTablePtr Index of table.
- *
- */
- void ADC_LoadYPPTable(UINT8 ucTablePtr);
- /**
- * @brief Load information of Vesa timing structure for VGA.
- *
- * This function update Vesa timing structure of VGA according to computation result of
- * related horizontal and vertical factors.
- *
- * @param ucTablePtr Index of table.
- *
- */
- void ADC_LoadVesaTable(UINT8 ucTablePtr);
- /**
- * @brief Determine whether to further check Vsync width if there are conflict timing modes.
- *
- * This function checks whether there is ambiguous timing according to comparing contents of
- * timing table. Furthermore, additional Vsync width comparison should be checked in the next step.
- *
- * @return Confirm result.
- *
- */
- BOOL ADC_NeedCheckVsyncWidth(void);
- /**
- * @brief Determine whether to further check Hsync width if there are conflict timing modes.
- *
- * This function checks whether there is ambiguous timing according to comparing contents of
- * timing table. Furthermore, additional Hsync width comparison should be checked in the next step.
- *
- * @return Confirm result.
- *
- */
- BOOL ADC_NeedCheckHsyncWidth(void);
- /**
- * @brief Determine whether to further check Polarity if there are conflict timing modes.
- *
- * This function checks whether there is ambiguous timing according to comparing contents of
- * timing table. Furthermore, additional polarity comparison should be checked in the next step.
- *
- * @return Confirm result.
- *
- */
- BOOL ADC_NeedToCheckPolarity(void);
- /**
- * @brief Check whether vertical frequency is proper or not.
- *
- * This function checks the range of vertical frequency, and report not support if the frequency
- * is out of specific range on reference source.
- *
- * @return Confirm result.
- *
- */
- BOOL ADC_Frequency_Filter(void);
- /**
- * @brief Update HV polarity and interlace information.
- *
- * This function updates flags related to Horizontal/Vertical polarity and interlace.
- *
- * @param ucFlag Status for write back into flags.
- *
- */
- void ADC_UpdateFlag(UINT8 ucFlag);
- /**
- * @brief Update current Horizontal count and Vertical count.
- *
- * This function updates current ADC information about horizontal and vertical counts.
- *
- */
- void ADC_StatusUpdate(void);
- /**
- * @brief Display screen according to screen mode.
- *
- * This function sends information to VIP according to input screen type.
- *
- * @param ucScreenMode Screen mode type (NormalScreen, BlackScreen)
- *
- */
- void ADC_ScreenMode(UINT8 ucScreenMode);
- /**
- * @brief Create work for mode detection.
- *
- * This function adds work thread into sync detection workqueue for mode detection.
- * If the detection procedure is done, revise flag to force doing mode detection again.
- *
- */
- void ADC_SyncDetectCreate(void);
- /**
- * @brief Print memory information when executing memory test procedure.
- *
- * This function print debugging message about the status of total memory
- * and free memory if memory test configuration is enabled.
- *
- * @param msg message for print in the end of memory status.
- *
- */
- void print_meminfo(INT8 *msg);
- /**
- * @brief Clock of ADC module.
- *
- * This function calculates system clock for ADC usage. The formula is
- * system_clk x [R_CPLL_MUL(0xbe0001b8[7:0]) + 1]
- * ¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w¢w
- * [R_CPLL_DIV(0xbe0001b8[12:8]) + 1] x [R_YPP200M_DIV(0xbe000158[6:0]) + 1]
- *
- * @return Clock value for ADC module.
- *
- */
- UINT32 ADC_MClk(void);
- /**
- * @brief Send event to KMF according to detecting status.
- *
- * This function notifies KMF by sending event ID accompany with information.
- * Two kind of messages are available in ADC moodule,
- * - ADCMSG_INPUTPATHSTATUS => notify KMF current signals status of ADC module.
- * - NOTICEMSG_ADC_TURNOFFSOUND => request KMF to turn off sound on ADC source.
- *
- * @param msgType Message type for sending.
- * @param bActive Whether currect signals is stable or not
- * @param bNotSupport Whther current signal is supported or not.
- *
- */
- void ADC_NoticeKmf(INT32 msgType, BOOL bActive, BOOL bNotSupport);
- /**
- * @brief Reset ADC flags to default status.
- *
- * This function resets several flags relating to ADC detecting flow.
- * These flags should be reset before timing mode detection,.
- *
- */
- void ADC_ResetAdcInfoSetting(void);
- /**
- * @brief Find matching timing mode in VGA table.
- *
- * This function checks specific rules and looks up matching VGA timing mode.
- *
- */
- void ADC_CheckVGATable(void);
- /**
- * @brief Find matching timing mode in YPP table.
- *
- * This function checks specific rules and looks up matching YPP timing mode.
- *
- */
- void ADC_CheckYPPTable(void);
- /**
- * @brief Check timing mode depending on request table type.
- *
- * This function looks up matching timing mode according to requested type.
- *
- */
- void ADC_CheckInputMatch(UINT8 ucTable);
- /**
- * @brief Find timing mode depending on source type.
- *
- * This function looks up timing mode tables according to input source type, and
- * reports unsupport if the timing cannot be found in table list.
- *
- * @return Supporting source mode or unsupport.
- *
- */
- UINT8 ADC_FindTimingModeTable(void);
- /**
- * @brief Check whether input signal can be supported or not.
- *
- * This function checks frequency filter and timing tables, and then updates the status
- * after checking.
- *
- * @return Whether input signal is supported.
- *
- */
- BOOL ADC_Detect_Mode(void);
- /**
- * @brief Reset flags for ADC AP.
- *
- * This function resets flags which are used by ADC AP.
- *
- */
- void ADC_ResetApSetting(void);
- /**
- * @brief Record chip information to flag.
- *
- * This function saves chip information to flag ulChipID by reading global register.
- * The bits[23:8] of ulChipID indicates the device chip ID(e.g. 0x331 -> 331 chip, 0x533 -> 533 chip.),
- * and the bits[7:0] indicates the revision ID(e.g. 0x10 -> A0 revision, 0x31 -> C1 revision).
- *
- */
- void ADC_SystemChipID(void);
- /**
- * @brief Check horizontal total and pixel clock range to decide enlarge width rate.
- *
- * This function gets horizontal total and pixel clock value from referenced timing table,
- * and then check its range for determining the rate of enlarge width iEnlargeWidthRate.
- * The iEnlargeWidthRate would be used to calculate horizontal related information.
- *
- */
- void ADC_OverSample(void);
- /**
- * @brief Update white balance related parameters for OSD updating usage.
- *
- * This function saves R,G and B gain control and digital offset values, which are used to
- * update OSD gain and offset status of RGB separately.
- *
- */
- void ADC_UpdateWBOSDvalue(void);
- /**
- * @brief Execute phase detection for the second round.
- *
- * This function sets different phases for frame comparison, and then select one best phase which
- * has the least difference summation.
- *
- */
- void ADC_PhaseDetectedSecond(void);
- /**
- * @brief Check whether detected signal is interlace mode or not.
- *
- * This function checks the difference of Vcount to distinguish current signal is
- * interlace type or progress type.
- *
- */
- BOOL ADC_CheckInterlaceMode(void);
- /**
- * @brief Search gain value for the first time processing white balance.
- *
- * This function checks whether it is the first time to execute white balance or not.
- * If it is not the first time white balance procedure, the gain value would be set
- * according to current status.
- *
- */
- void ADC_FirstTimeSearchGain(void);
- /**
- * @brief Check whether gain value is located in specific range.
- *
- * This function checks input gain value, and returns TRUE if the value is not a proper value.
- *
- * @param scValue Gain value for checking.
- *
- */
- BOOL ADC_CheckGainValue(UINT16 scValue);
- /**
- * @brief Read data according to address.
- *
- * This function gets value of requested register, the format of requesting register includes
- * start/end bits and its address.
- *
- * @param uiAdr Request address format using 32 bits data
- * [28] => 1: Global BASE registers (0xbe000000~);
- * 0: ADC BASE registers (0xbe150000~);
- * [25:21] => Starting bit position
- * [20:16] => Ending bit position
- * [15:0] => Offset value from BASE address
- * @return Data read from referenced address
- *
- */
- UINT32 ADC_Read(UINT32 uiAdr);
- /**
- * @brief Write data according to address.
- *
- * This function writes value into requested register, the format of register includes
- * start/end bits and its address.
- *
- * @param uiAdr Request address format using 32 bits data
- * [28] => 1: Global BASE registers (0xbe000000~);
- * 0: ADC BASE registers (0xbe150000~);
- * [25:21] => Starting bit position
- * [20:16] => Ending bit position
- * [15:0] => Offset value from BASE address
- * @param uiDat Data for writing.
- *
- */
- void ADC_Write(UINT32 uiAdr, UINT32 uiDat);
- /**
- * @brief Find the most close gain value for RGB.
- *
- * This function searches gain value which has the least difference comparing with target value.
- * It would process iterately setting gain and checking delta on RGB channels.
- *
- */
- void ADC_SearchDigitalOffset(void);
- /**
- * @brief Enable/Disable ADC related power and clock.
- *
- * This function setups power down bits and related clock for enable/disable ADC module.
- *
- * @param bPowerOn Switch for power on or power off.
- *
- */
- INT32 DRV_ADC_power(INT32 bPowerOn);
- /**
- * @brief Provide current dg status for CVD2 closed caption decoding.
- *
- * This function provides dg status for video decoder. Decoder would set vbi line select
- * depending on dg status.
- *
- * @return Current dg status.
- *
- */
- UINT8 DRV_ADC_DgSourceStatus(void);
- /**
- * @brief Adjust function for app layer.
- *
- * This function contains several commands for app layer usage.
- *
- * @param ucFunID Request Funciton ID .
- * @param iValue Request value for function.
- *
- */
- INT32 adc_AdjustFunction(UINT8 ucFunID, INT32 iValue);
- /**
- * @brief Auto white balance.
- *
- * This function processes white balance by searching best gain and offset for RGB channels separately.
- *
- */
- void ADC_AutoColorCalibration(void);
- /**
- * @brief Fetch customer table data for VGA, YPP and Scart.
- *
- * This function gets VGA, YPP and Scart timing tables from customized default setting.
- *
- */
- void ADC_GetVideoTimingTable(void);
- /**
- * @brief Sets input pin according to source.
- *
- * This function setups related input pins, including R/G/B, Y/C, YCbCr, SOG and CVBS
- * according to input source type.
- *
- */
- void DRV_ADC_SetAdcPinConfig(UINT32 itype, InputVideoConf_st InputSrcPin);
- #endif
|