tvafe_adc.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*******************************************************************
  2. * Copyright C 2010 by Amlogic, Inc. All Rights Reserved.
  3. * File name: TVAFE_ADC.h
  4. * Description: IO function, structure, enum, used in TVIN AFE sub-module processing
  5. *******************************************************************/
  6. #ifndef _TVAFE_ADC_H
  7. #define _TVAFE_ADC_H
  8. // ***************************************************************************
  9. // *** enum definitions *********************************************
  10. // ***************************************************************************
  11. //auto clock detection state machine
  12. typedef enum tvafe_vga_auto_clk_state_e {
  13. VGA_CLK_IDLE,
  14. VGA_CLK_INIT,
  15. VGA_CLK_ROUGH_ADJ,
  16. VGA_CLK_FINE_ADJ,
  17. VGA_CLK_EXCEPTION,
  18. VGA_CLK_END,
  19. } tvafe_vga_auto_clk_state_t;
  20. //auto phase state machine
  21. typedef enum tvafe_vga_auto_phase_state_e {
  22. VGA_PHASE_IDLE,
  23. VGA_PHASE_INIT, //auto phase init
  24. VGA_PHASE_SEARCH_WIN,
  25. VGA_PHASE_ADJ, //write all the phase value, get the best value by the sum value
  26. VGA_PHASE_EXCEPTION,
  27. VGA_PHASE_END,
  28. } tvafe_vga_auto_phase_state_t;
  29. // ***************************************************************************
  30. // *** structure definitions *********************************************
  31. // ***************************************************************************
  32. typedef struct tvafe_vga_auto_win_s {
  33. unsigned int hstart;
  34. unsigned int hend;
  35. unsigned int vstart;
  36. unsigned int vend;
  37. } tvafe_vga_auto_win_t;
  38. #define VGA_PHASE_WIN_INDEX_0 0
  39. #define VGA_PHASE_WIN_INDEX_1 1
  40. #define VGA_PHASE_WIN_INDEX_2 2
  41. #define VGA_PHASE_WIN_INDEX_3 3
  42. #define VGA_PHASE_WIN_INDEX_4 4
  43. #define VGA_PHASE_WIN_INDEX_5 5
  44. #define VGA_PHASE_WIN_INDEX_6 6
  45. #define VGA_PHASE_WIN_INDEX_7 7
  46. #define VGA_PHASE_WIN_INDEX_8 8
  47. #define VGA_PHASE_WIN_INDEX_MAX VGA_PHASE_WIN_INDEX_8
  48. #define VGA_ADC_PHASE_0 0
  49. #define VGA_ADC_PHASE_1 1
  50. #define VGA_ADC_PHASE_2 2
  51. #define VGA_ADC_PHASE_3 3
  52. #define VGA_ADC_PHASE_4 4
  53. #define VGA_ADC_PHASE_5 5
  54. #define VGA_ADC_PHASE_6 6
  55. #define VGA_ADC_PHASE_7 7
  56. #define VGA_ADC_PHASE_8 8
  57. #define VGA_ADC_PHASE_9 9
  58. #define VGA_ADC_PHASE_10 10
  59. #define VGA_ADC_PHASE_11 11
  60. #define VGA_ADC_PHASE_12 12
  61. #define VGA_ADC_PHASE_13 13
  62. #define VGA_ADC_PHASE_14 14
  63. #define VGA_ADC_PHASE_15 15
  64. #define VGA_ADC_PHASE_16 16
  65. #define VGA_ADC_PHASE_17 17
  66. #define VGA_ADC_PHASE_18 18
  67. #define VGA_ADC_PHASE_19 19
  68. #define VGA_ADC_PHASE_20 20
  69. #define VGA_ADC_PHASE_21 21
  70. #define VGA_ADC_PHASE_22 22
  71. #define VGA_ADC_PHASE_23 23
  72. #define VGA_ADC_PHASE_24 24
  73. #define VGA_ADC_PHASE_25 25
  74. #define VGA_ADC_PHASE_26 26
  75. #define VGA_ADC_PHASE_27 27
  76. #define VGA_ADC_PHASE_28 28
  77. #define VGA_ADC_PHASE_29 29
  78. #define VGA_ADC_PHASE_30 30
  79. #define VGA_ADC_PHASE_31 31
  80. #define VGA_ADC_PHASE_MID VGA_ADC_PHASE_15
  81. #define VGA_ADC_PHASE_MAX VGA_ADC_PHASE_31
  82. typedef struct tvafe_vga_auto_state_s {
  83. enum tvafe_vga_auto_clk_state_e clk_state;
  84. enum tvafe_vga_auto_phase_state_e phase_state;
  85. unsigned char ap_win_index;
  86. unsigned char ap_winmax_index;
  87. unsigned char ap_pha_index;
  88. unsigned char ap_phamax_index;
  89. unsigned char vs_cnt;
  90. unsigned char adj_cnt;
  91. signed char adj_dir;
  92. unsigned int ap_max_diff;
  93. struct tvafe_vga_auto_win_s win;
  94. } tvafe_vga_auto_state_t;
  95. // *****************************************************************************
  96. // ******** GLOBAL FUNCTION CLAIM ********
  97. // *****************************************************************************
  98. void tvafe_adc_set_param(struct tvafe_vga_parm_s *adc_parm, struct tvafe_info_s *info);
  99. void tvafe_adc_get_param(struct tvafe_vga_parm_s *adc_parm, struct tvafe_info_s *info);
  100. void tvafe_vga_vs_cnt(void);
  101. void tvafe_vga_auto_adjust_handler(struct tvafe_info_s *info);
  102. int tvafe_vga_auto_adjust_enable(struct tvafe_info_s *info);
  103. void tvafe_vga_auto_adjust_disable(struct tvafe_info_s *info);
  104. bool tvafe_adc_no_sig(void);
  105. bool tvafe_adc_fmt_chg(struct tvafe_info_s *info);//(enum tvafe_src_type_e src_type, struct tvin_parm_s *parm);
  106. bool tvafe_adc_get_pll_status(void);
  107. enum tvin_sig_fmt_e tvafe_adc_search_mode(enum tvafe_src_type_e src_type);
  108. void tvafe_set_vga_default(enum tvin_sig_fmt_e fmt);
  109. void tvafe_set_comp_default(enum tvin_sig_fmt_e fmt);
  110. void tvafe_adc_configure(enum tvin_sig_fmt_e fmt);
  111. void tvafe_adc_state_init(void);
  112. void tvafe_adc_digital_reset(void);
  113. #endif // _TVAFE_ADC_H