dibx000_common.h 6.1 KB

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