dibx000_common.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  1. #ifndef DIBX000_COMMON_H
  2. #define DIBX000_COMMON_H
  3. enum dibx000_i2c_interface {
  4. DIBX000_I2C_INTERFACE_TUNER = 0,
  5. DIBX000_I2C_INTERFACE_GPIO_1_2 = 1,
  6. DIBX000_I2C_INTERFACE_GPIO_3_4 = 2,
  7. DIBX000_I2C_INTERFACE_GPIO_6_7 = 3
  8. };
  9. struct dibx000_i2c_master {
  10. #define DIB3000MC 1
  11. #define DIB7000 2
  12. #define DIB7000P 11
  13. #define DIB7000MC 12
  14. #define DIB8000 13
  15. u16 device_rev;
  16. enum dibx000_i2c_interface selected_interface;
  17. /* struct i2c_adapter tuner_i2c_adap; */
  18. struct i2c_adapter gated_tuner_i2c_adap;
  19. struct i2c_adapter master_i2c_adap_gpio12;
  20. struct i2c_adapter master_i2c_adap_gpio34;
  21. struct i2c_adapter master_i2c_adap_gpio67;
  22. struct i2c_adapter *i2c_adap;
  23. u8 i2c_addr;
  24. u16 base_reg;
  25. /* for the I2C transfer */
  26. struct i2c_msg msg[34];
  27. u8 i2c_write_buffer[8];
  28. u8 i2c_read_buffer[2];
  29. struct mutex i2c_buffer_lock;
  30. };
  31. extern int dibx000_init_i2c_master(struct dibx000_i2c_master *mst,
  32. u16 device_rev, struct i2c_adapter *i2c_adap,
  33. u8 i2c_addr);
  34. extern struct i2c_adapter *dibx000_get_i2c_adapter(struct dibx000_i2c_master
  35. *mst,
  36. enum dibx000_i2c_interface
  37. intf, int gating);
  38. extern void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst);
  39. extern void dibx000_reset_i2c_master(struct dibx000_i2c_master *mst);
  40. extern int dibx000_i2c_set_speed(struct i2c_adapter *i2c_adap, u16 speed);
  41. extern u32 systime(void);
  42. #define BAND_LBAND 0x01
  43. #define BAND_UHF 0x02
  44. #define BAND_VHF 0x04
  45. #define BAND_SBAND 0x08
  46. #define BAND_FM 0x10
  47. #define BAND_CBAND 0x20
  48. #define BAND_OF_FREQUENCY(freq_kHz) ((freq_kHz) <= 170000 ? BAND_CBAND : \
  49. (freq_kHz) <= 115000 ? BAND_FM : \
  50. (freq_kHz) <= 250000 ? BAND_VHF : \
  51. (freq_kHz) <= 863000 ? BAND_UHF : \
  52. (freq_kHz) <= 2000000 ? BAND_LBAND : BAND_SBAND )
  53. struct dibx000_agc_config {
  54. /* defines the capabilities of this AGC-setting - using the BAND_-defines */
  55. u8 band_caps;
  56. u16 setup;
  57. u16 inv_gain;
  58. u16 time_stabiliz;
  59. u8 alpha_level;
  60. u16 thlock;
  61. u8 wbd_inv;
  62. u16 wbd_ref;
  63. u8 wbd_sel;
  64. u8 wbd_alpha;
  65. u16 agc1_max;
  66. u16 agc1_min;
  67. u16 agc2_max;
  68. u16 agc2_min;
  69. u8 agc1_pt1;
  70. u8 agc1_pt2;
  71. u8 agc1_pt3;
  72. u8 agc1_slope1;
  73. u8 agc1_slope2;
  74. u8 agc2_pt1;
  75. u8 agc2_pt2;
  76. u8 agc2_slope1;
  77. u8 agc2_slope2;
  78. u8 alpha_mant;
  79. u8 alpha_exp;
  80. u8 beta_mant;
  81. u8 beta_exp;
  82. u8 perform_agc_softsplit;
  83. struct {
  84. u16 min;
  85. u16 max;
  86. u16 min_thres;
  87. u16 max_thres;
  88. } split;
  89. };
  90. struct dibx000_bandwidth_config {
  91. u32 internal;
  92. u32 sampling;
  93. u8 pll_prediv;
  94. u8 pll_ratio;
  95. u8 pll_range;
  96. u8 pll_reset;
  97. u8 pll_bypass;
  98. u8 enable_refdiv;
  99. u8 bypclk_div;
  100. u8 IO_CLK_en_core;
  101. u8 ADClkSrc;
  102. u8 modulo;
  103. u16 sad_cfg;
  104. u32 ifreq;
  105. u32 timf;
  106. u32 xtal_hz;
  107. };
  108. enum dibx000_adc_states {
  109. DIBX000_SLOW_ADC_ON = 0,
  110. DIBX000_SLOW_ADC_OFF,
  111. DIBX000_ADC_ON,
  112. DIBX000_ADC_OFF,
  113. DIBX000_VBG_ENABLE,
  114. DIBX000_VBG_DISABLE,
  115. };
  116. #define BANDWIDTH_TO_KHZ(v) ((v) == BANDWIDTH_8_MHZ ? 8000 : \
  117. (v) == BANDWIDTH_7_MHZ ? 7000 : \
  118. (v) == BANDWIDTH_6_MHZ ? 6000 : 8000)
  119. #define BANDWIDTH_TO_INDEX(v) ( \
  120. (v) == 8000 ? BANDWIDTH_8_MHZ : \
  121. (v) == 7000 ? BANDWIDTH_7_MHZ : \
  122. (v) == 6000 ? BANDWIDTH_6_MHZ : BANDWIDTH_8_MHZ )
  123. /* Chip output mode. */
  124. #define OUTMODE_HIGH_Z 0
  125. #define OUTMODE_MPEG2_PAR_GATED_CLK 1
  126. #define OUTMODE_MPEG2_PAR_CONT_CLK 2
  127. #define OUTMODE_MPEG2_SERIAL 7
  128. #define OUTMODE_DIVERSITY 4
  129. #define OUTMODE_MPEG2_FIFO 5
  130. #define OUTMODE_ANALOG_ADC 6
  131. #define INPUT_MODE_OFF 0x11
  132. #define INPUT_MODE_DIVERSITY 0x12
  133. #define INPUT_MODE_MPEG 0x13
  134. enum frontend_tune_state {
  135. CT_TUNER_START = 10,
  136. CT_TUNER_STEP_0,
  137. CT_TUNER_STEP_1,
  138. CT_TUNER_STEP_2,
  139. CT_TUNER_STEP_3,
  140. CT_TUNER_STEP_4,
  141. CT_TUNER_STEP_5,
  142. CT_TUNER_STEP_6,
  143. CT_TUNER_STEP_7,
  144. CT_TUNER_STOP,
  145. CT_AGC_START = 20,
  146. CT_AGC_STEP_0,
  147. CT_AGC_STEP_1,
  148. CT_AGC_STEP_2,
  149. CT_AGC_STEP_3,
  150. CT_AGC_STEP_4,
  151. CT_AGC_STOP,
  152. CT_DEMOD_START = 30,
  153. CT_DEMOD_STEP_1,
  154. CT_DEMOD_STEP_2,
  155. CT_DEMOD_STEP_3,
  156. CT_DEMOD_STEP_4,
  157. CT_DEMOD_STEP_5,
  158. CT_DEMOD_STEP_6,
  159. CT_DEMOD_STEP_7,
  160. CT_DEMOD_STEP_8,
  161. CT_DEMOD_STEP_9,
  162. CT_DEMOD_STEP_10,
  163. CT_DEMOD_SEARCH_NEXT = 41,
  164. CT_DEMOD_STEP_LOCKED,
  165. CT_DEMOD_STOP,
  166. CT_DONE = 100,
  167. CT_SHUTDOWN,
  168. };
  169. struct dvb_frontend_parametersContext {
  170. #define CHANNEL_STATUS_PARAMETERS_UNKNOWN 0x01
  171. #define CHANNEL_STATUS_PARAMETERS_SET 0x02
  172. u8 status;
  173. u32 tune_time_estimation[2];
  174. s32 tps_available;
  175. u16 tps[9];
  176. };
  177. #define FE_STATUS_TUNE_FAILED 0
  178. #define FE_STATUS_TUNE_TIMED_OUT -1
  179. #define FE_STATUS_TUNE_TIME_TOO_SHORT -2
  180. #define FE_STATUS_TUNE_PENDING -3
  181. #define FE_STATUS_STD_SUCCESS -4
  182. #define FE_STATUS_FFT_SUCCESS -5
  183. #define FE_STATUS_DEMOD_SUCCESS -6
  184. #define FE_STATUS_LOCKED -7
  185. #define FE_STATUS_DATA_LOCKED -8
  186. #define FE_CALLBACK_TIME_NEVER 0xffffffff
  187. #define ABS(x) ((x < 0) ? (-x) : (x))
  188. #define DATA_BUS_ACCESS_MODE_8BIT 0x01
  189. #define DATA_BUS_ACCESS_MODE_16BIT 0x02
  190. #define DATA_BUS_ACCESS_MODE_NO_ADDRESS_INCREMENT 0x10
  191. struct dibGPIOFunction {
  192. #define BOARD_GPIO_COMPONENT_BUS_ADAPTER 1
  193. #define BOARD_GPIO_COMPONENT_DEMOD 2
  194. u8 component;
  195. #define BOARD_GPIO_FUNCTION_BOARD_ON 1
  196. #define BOARD_GPIO_FUNCTION_BOARD_OFF 2
  197. #define BOARD_GPIO_FUNCTION_COMPONENT_ON 3
  198. #define BOARD_GPIO_FUNCTION_COMPONENT_OFF 4
  199. #define BOARD_GPIO_FUNCTION_SUBBAND_PWM 5
  200. #define BOARD_GPIO_FUNCTION_SUBBAND_GPIO 6
  201. u8 function;
  202. /* mask, direction and value are used specify which GPIO to change GPIO0
  203. * is LSB and possible GPIO31 is MSB. The same bit-position as in the
  204. * mask is used for the direction and the value. Direction == 1 is OUT,
  205. * 0 == IN. For direction "OUT" value is either 1 or 0, for direction IN
  206. * value has no meaning.
  207. *
  208. * In case of BOARD_GPIO_FUNCTION_PWM mask is giving the GPIO to be
  209. * used to do the PWM. Direction gives the PWModulator to be used.
  210. * Value gives the PWM value in device-dependent scale.
  211. */
  212. u32 mask;
  213. u32 direction;
  214. u32 value;
  215. };
  216. #define MAX_NB_SUBBANDS 8
  217. struct dibSubbandSelection {
  218. u8 size; /* Actual number of subbands. */
  219. struct {
  220. u16 f_mhz;
  221. struct dibGPIOFunction gpio;
  222. } subband[MAX_NB_SUBBANDS];
  223. };
  224. #define DEMOD_TIMF_SET 0x00
  225. #define DEMOD_TIMF_GET 0x01
  226. #define DEMOD_TIMF_UPDATE 0x02
  227. #define MPEG_ON_DIBTX 1
  228. #define DIV_ON_DIBTX 2
  229. #define ADC_ON_DIBTX 3
  230. #define DEMOUT_ON_HOSTBUS 4
  231. #define DIBTX_ON_HOSTBUS 5
  232. #define MPEG_ON_HOSTBUS 6
  233. #endif