tvin_global.h 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*
  2. * TVIN global definition
  3. * enum, structure & global parameters used in all TVIN modules.
  4. *
  5. * Author: Lin Xu <lin.xu@amlogic.com>
  6. * Bobby Yang <bo.yang@amlogic.com>
  7. *
  8. * Copyright (C) 2010 Amlogic Inc.
  9. *
  10. * This program is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License version 2 as
  12. * published by the Free Software Foundation.
  13. */
  14. #ifndef __TVIN_GLOBAL_H
  15. #define __TVIN_GLOBAL_H
  16. #include <linux/tvin/tvin.h>
  17. // ***************************************************************************
  18. // *** enum definitions *********************************************
  19. // ***************************************************************************
  20. #define STATUS_ANTI_SHOCKING 3
  21. #define MINIMUM_H_CNT 1400
  22. #define ADC_REG_NUM 112
  23. #define CVD_PART1_REG_NUM 64
  24. #define CVD_PART1_REG_MIN 0x00
  25. #define CVD_PART2_REG_NUM 144
  26. #define CVD_PART2_REG_MIN 0x70
  27. #define CVD_PART3_REG_NUM 7 // 0x87, 0x93, 0x94, 0x95, 0x96, 0xe6, 0xfa
  28. #define CVD_PART3_REG_0 0x87
  29. #define CVD_PART3_REG_1 0x93
  30. #define CVD_PART3_REG_2 0x94
  31. #define CVD_PART3_REG_3 0x95
  32. #define CVD_PART3_REG_4 0x96
  33. #define CVD_PART3_REG_5 0xe6
  34. #define CVD_PART3_REG_6 0xfa
  35. #define ACD_REG_MAX 0x32 //0x00-0x32 except 0x1E&0x31
  36. #define CRYSTAL_24M
  37. #ifndef CRYSTAL_24M
  38. #define CRYSTAL_25M
  39. #endif
  40. #ifdef CRYSTAL_24M
  41. #define CVD2_CHROMA_DTO_NTSC_M 0x262e8ba2
  42. #define CVD2_CHROMA_DTO_NTSC_443 0x2f4abc24
  43. #define CVD2_CHROMA_DTO_PAL_I 0x2f4abc24
  44. #define CVD2_CHROMA_DTO_PAL_M 0x2623cd98
  45. #define CVD2_CHROMA_DTO_PAL_CN 0x263566cf
  46. #define CVD2_CHROMA_DTO_PAL_60 0x2f4abc24
  47. #define CVD2_CHROMA_DTO_SECAM 0x2db7a328
  48. #define CVD2_HSYNC_DTO_NTSC_M 0x24000000
  49. #define CVD2_HSYNC_DTO_NTSC_443 0x24000000
  50. #define CVD2_HSYNC_DTO_PAL_I 0x24000000
  51. #define CVD2_HSYNC_DTO_PAL_M 0x24000000
  52. #define CVD2_HSYNC_DTO_PAL_CN 0x24000000
  53. #define CVD2_HSYNC_DTO_PAL_60 0x24000000
  54. #define CVD2_HSYNC_DTO_SECAM 0x24000000
  55. #define CVD2_DCRESTORE_ACCUM 0x98 // [5:0] = 24(MHz)
  56. #endif
  57. #ifdef CRYSTAL_25M
  58. #define CVD2_CHROMA_DTO_NTSC_M 0x24a7904a
  59. #define CVD2_CHROMA_DTO_NTSC_443 0x2d66772d
  60. #define CVD2_CHROMA_DTO_PAL_I 0x2d66772d
  61. #define CVD2_CHROMA_DTO_PAL_M 0x249d4040
  62. #define CVD2_CHROMA_DTO_PAL_CN 0x24ae2541
  63. #define CVD2_CHROMA_DTO_PAL_60 0x2d66772d
  64. #define CVD2_CHROMA_DTO_SECAM 0x2be37de9
  65. #define CVD2_HSYNC_DTO_NTSC_M 0x228f5c28
  66. #define CVD2_HSYNC_DTO_NTSC_443 0x228f5c28
  67. #define CVD2_HSYNC_DTO_PAL_I 0x228f5c28
  68. #define CVD2_HSYNC_DTO_PAL_M 0x228f5c28
  69. #define CVD2_HSYNC_DTO_PAL_CN 0x228f5c28
  70. #define CVD2_HSYNC_DTO_PAL_60 0x228f5c28
  71. #define CVD2_HSYNC_DTO_SECAM 0x228f5c28
  72. #define CVD2_DCRESTORE_ACCUM 0x99 // [5:0] = 25(MHz)
  73. #endif
  74. #if defined(CONFIG_MESON2_CHIP_B)
  75. #define TVAFE_ADC_CVBS_CLAMP_SEQUENCE_EN
  76. #endif
  77. #ifdef TVAFE_ADC_CVBS_CLAMP_SEQUENCE_EN
  78. #define ADC_CVBS_CLAMP_SEQUENCE0_LEN 627
  79. #define ADC_CVBS_CLAMP_SEQUENCE1_LEN 468
  80. #define ADC_CVBS_CLAMP_SEQUENCE2_LEN 282
  81. #define ADC_CVBS_CLAMP_SEQUENCE3_LEN 96
  82. #define ADC_CVBS_CLAMP_SEQUENCE4_LEN 1
  83. #endif
  84. #define TVAFE_SET_CVBS_PGA_EN
  85. #ifdef TVAFE_SET_CVBS_PGA_EN
  86. #define TVAFE_SET_CVBS_PGA_START 5
  87. #define TVAFE_SET_CVBS_PGA_STEP 1
  88. #define CVD2_DGAIN_MIDDLE 0x0200
  89. #define CVD2_DGAIN_WINDOW 0x000F
  90. #define CVD2_DGAIN_LIMITH CVD2_DGAIN_MIDDLE + CVD2_DGAIN_WINDOW
  91. #define CVD2_DGAIN_LIMITL CVD2_DGAIN_MIDDLE - CVD2_DGAIN_WINDOW
  92. #endif
  93. #define TVAFE_SET_CVBS_CDTO_EN
  94. #ifdef TVAFE_SET_CVBS_CDTO_EN
  95. #define TVAFE_SET_CVBS_CDTO_START 300
  96. #define TVAFE_SET_CVBS_CDTO_STEP 0
  97. #define HS_CNT_STANDARD 0x17a00
  98. #endif
  99. //#define TVAFE_SET_CVBS_MANUAL_FMT_POS //enable manual format video position setting
  100. typedef enum tvin_sync_pol_e {
  101. TVIN_SYNC_POL_NULL = 0,
  102. TVIN_SYNC_POL_NEGATIVE,
  103. TVIN_SYNC_POL_POSITIVE,
  104. } tvin_sync_pol_t;
  105. typedef enum tvin_scan_mode_e {
  106. TVIN_SCAN_MODE_NULL = 0,
  107. TVIN_SCAN_MODE_PROGRESSIVE,
  108. TVIN_SCAN_MODE_INTERLACED,
  109. } tvin_scan_mode_t;
  110. typedef enum tvin_color_space_e {
  111. TVIN_CS_RGB444 = 0,
  112. TVIN_CS_YUV444,
  113. TVIN_CS_YUV422_16BITS,
  114. TVIN_CS_YCbCr422_8BITS,
  115. TVIN_CS_MAX
  116. } tvin_color_space_t;
  117. #ifdef TVAFE_SET_CVBS_MANUAL_FMT_POS
  118. /* cvbs manual format video postion setting */
  119. typedef enum tvin_cvbs_pos_ctl_e {
  120. TVIN_CVBS_POS_NULL = 1, //do not need change position
  121. TVIN_CVBS_POS_P_TO_N, //input is N, manual format is P, set N postion
  122. TVIN_CVBS_POS_P_TO_P, //input is P, manual format is P, reload P postion
  123. TVIN_CVBS_POS_N_TO_P, //input is P, manual format is N, set P postion
  124. TVIN_CVBS_POS_N_TO_N, //input is N, manual format is N, reload N postion
  125. } tvin_cvbs_pos_ctl_t;
  126. #endif
  127. // ***************************************************************************
  128. // *** structure definitions *********************************************
  129. // ***************************************************************************
  130. // Hs_cnt Pixel_Clk(Khz/10)
  131. typedef struct tvin_format_s {
  132. unsigned short h_active; //Th in the unit of pixel
  133. unsigned short v_active; //Tv in the unit of line
  134. unsigned short h_cnt; //Th in the unit of T, while 1/T = 24MHz or 27MHz or even 100MHz
  135. unsigned short h_cnt_offset; //Tolerance of h_cnt
  136. unsigned short v_cnt_offset; //Tolerance of v_cnt
  137. unsigned short hs_cnt; //Ths in the unit of T, while 1/T = 24MHz or 27MHz or even 100MHz
  138. unsigned short hs_cnt_offset; //Tolerance of hs_cnt
  139. unsigned short h_total; //Th in the unit of pixel
  140. unsigned short v_total; //Tv in the unit of line
  141. unsigned short hs_front; //h front proch
  142. unsigned short hs_width; //HS in the unit of pixel
  143. unsigned short hs_bp; //HS in the unit of pixel
  144. unsigned short vs_front; //vs front proch in the unit of line
  145. unsigned short vs_width; //VS width in the unit of line
  146. unsigned short vs_bp; //vs back proch in the unit of line
  147. enum tvin_sync_pol_e hs_pol;
  148. enum tvin_sync_pol_e vs_pol;
  149. enum tvin_scan_mode_e scan_mode;
  150. unsigned short pixel_clk; //(Khz/10)
  151. unsigned short vbi_line_start;
  152. unsigned short vbi_line_end;
  153. unsigned int duration;
  154. } tvin_format_t;
  155. typedef enum tvin_color_fmt_e {
  156. TVIN_RGB444 = 0,
  157. TVIN_YUV422,
  158. TVIN_YUV444,
  159. TVIN_COLOR_FMT_MAX,
  160. }tvin_color_fmt_t;
  161. const char *tvin_color_fmt_str(enum tvin_color_fmt_e color_fmt);
  162. typedef enum tvin_aspect_ratio_e {
  163. TVIN_ASPECT_NULL = 0,
  164. TVIN_ASPECT_1x1,
  165. TVIN_ASPECT_4x3,
  166. TVIN_ASPECT_16x9,
  167. TVIN_ASPECT_MAX,
  168. } tvin_aspect_ratio_t;
  169. const char *tvin_aspect_ratio_str(enum tvin_aspect_ratio_e aspect_ratio);
  170. typedef struct tvin_sig_property_s {
  171. enum tvin_trans_fmt trans_fmt;
  172. enum tvin_color_fmt_e color_format;
  173. enum tvin_aspect_ratio_e aspect_ratio;
  174. unsigned int pixel_repeat;
  175. } tvin_sig_property_t;
  176. #define TVAFE_VF_POOL_SIZE 6//8
  177. #define VDIN_VF_POOL_MAX_SIZE 6//8
  178. #define TVHDMI_VF_POOL_SIZE 6//8
  179. #define BT656IN_ANCI_DATA_SIZE 0x4000 //save anci data from bt656in
  180. #define CAMERA_IN_ANCI_DATA_SIZE 0x4000 //save anci data from bt656in
  181. #endif // __TVIN_GLOBAL_H