dibx000_common.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. };
  8. struct dibx000_i2c_master {
  9. #define DIB3000MC 1
  10. #define DIB7000 2
  11. #define DIB7000P 11
  12. #define DIB7000MC 12
  13. u16 device_rev;
  14. enum dibx000_i2c_interface selected_interface;
  15. // struct i2c_adapter tuner_i2c_adap;
  16. struct i2c_adapter gated_tuner_i2c_adap;
  17. struct i2c_adapter *i2c_adap;
  18. u8 i2c_addr;
  19. u16 base_reg;
  20. };
  21. extern int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev, struct i2c_adapter *i2c_adap, u8 i2c_addr);
  22. extern struct i2c_adapter * dibx000_get_i2c_adapter(struct dibx000_i2c_master *mst, enum dibx000_i2c_interface intf, int gating);
  23. extern void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst);
  24. #define BAND_LBAND 0x01
  25. #define BAND_UHF 0x02
  26. #define BAND_VHF 0x04
  27. #define BAND_SBAND 0x08
  28. #define BAND_FM 0x10
  29. #define BAND_OF_FREQUENCY(freq_kHz) ( (freq_kHz) <= 115000 ? BAND_FM : \
  30. (freq_kHz) <= 250000 ? BAND_VHF : \
  31. (freq_kHz) <= 863000 ? BAND_UHF : \
  32. (freq_kHz) <= 2000000 ? BAND_LBAND : BAND_SBAND )
  33. struct dibx000_agc_config {
  34. /* defines the capabilities of this AGC-setting - using the BAND_-defines*/
  35. u8 band_caps;
  36. u16 setup;
  37. u16 inv_gain;
  38. u16 time_stabiliz;
  39. u8 alpha_level;
  40. u16 thlock;
  41. u8 wbd_inv;
  42. u16 wbd_ref;
  43. u8 wbd_sel;
  44. u8 wbd_alpha;
  45. u16 agc1_max;
  46. u16 agc1_min;
  47. u16 agc2_max;
  48. u16 agc2_min;
  49. u8 agc1_pt1;
  50. u8 agc1_pt2;
  51. u8 agc1_pt3;
  52. u8 agc1_slope1;
  53. u8 agc1_slope2;
  54. u8 agc2_pt1;
  55. u8 agc2_pt2;
  56. u8 agc2_slope1;
  57. u8 agc2_slope2;
  58. u8 alpha_mant;
  59. u8 alpha_exp;
  60. u8 beta_mant;
  61. u8 beta_exp;
  62. u8 perform_agc_softsplit;
  63. struct {
  64. u16 min;
  65. u16 max;
  66. u16 min_thres;
  67. u16 max_thres;
  68. } split;
  69. };
  70. struct dibx000_bandwidth_config {
  71. u32 internal;
  72. u32 sampling;
  73. u8 pll_prediv;
  74. u8 pll_ratio;
  75. u8 pll_range;
  76. u8 pll_reset;
  77. u8 pll_bypass;
  78. u8 enable_refdiv;
  79. u8 bypclk_div;
  80. u8 IO_CLK_en_core;
  81. u8 ADClkSrc;
  82. u8 modulo;
  83. u16 sad_cfg;
  84. u32 ifreq;
  85. u32 timf;
  86. };
  87. enum dibx000_adc_states {
  88. DIBX000_SLOW_ADC_ON = 0,
  89. DIBX000_SLOW_ADC_OFF,
  90. DIBX000_ADC_ON,
  91. DIBX000_ADC_OFF,
  92. DIBX000_VBG_ENABLE,
  93. DIBX000_VBG_DISABLE,
  94. };
  95. #define BW_INDEX_TO_KHZ(v) ( (v) == BANDWIDTH_8_MHZ ? 8000 : \
  96. (v) == BANDWIDTH_7_MHZ ? 7000 : \
  97. (v) == BANDWIDTH_6_MHZ ? 6000 : 8000 )
  98. /* Chip output mode. */
  99. #define OUTMODE_HIGH_Z 0
  100. #define OUTMODE_MPEG2_PAR_GATED_CLK 1
  101. #define OUTMODE_MPEG2_PAR_CONT_CLK 2
  102. #define OUTMODE_MPEG2_SERIAL 7
  103. #define OUTMODE_DIVERSITY 4
  104. #define OUTMODE_MPEG2_FIFO 5
  105. /* I hope I can get rid of the following kludge in the near future */
  106. struct dibx000_ofdm_channel {
  107. u32 RF_kHz;
  108. u8 Bw;
  109. s16 nfft;
  110. s16 guard;
  111. s16 nqam;
  112. s16 vit_hrch;
  113. s16 vit_select_hp;
  114. s16 vit_alpha;
  115. s16 vit_code_rate_hp;
  116. s16 vit_code_rate_lp;
  117. u8 intlv_native;
  118. };
  119. #define FEP2DIB(fep,ch) \
  120. (ch)->RF_kHz = (fep)->frequency / 1000; \
  121. (ch)->Bw = (fep)->u.ofdm.bandwidth; \
  122. (ch)->nfft = (fep)->u.ofdm.transmission_mode == TRANSMISSION_MODE_AUTO ? -1 : (fep)->u.ofdm.transmission_mode; \
  123. (ch)->guard = (fep)->u.ofdm.guard_interval == GUARD_INTERVAL_AUTO ? -1 : (fep)->u.ofdm.guard_interval; \
  124. (ch)->nqam = (fep)->u.ofdm.constellation == QAM_AUTO ? -1 : (fep)->u.ofdm.constellation == QAM_64 ? 2 : (fep)->u.ofdm.constellation; \
  125. (ch)->vit_hrch = 0; /* linux-dvb is not prepared for HIERARCHICAL TRANSMISSION */ \
  126. (ch)->vit_select_hp = 1; \
  127. (ch)->vit_alpha = 1; \
  128. (ch)->vit_code_rate_hp = (fep)->u.ofdm.code_rate_HP == FEC_AUTO ? -1 : (fep)->u.ofdm.code_rate_HP; \
  129. (ch)->vit_code_rate_lp = (fep)->u.ofdm.code_rate_LP == FEC_AUTO ? -1 : (fep)->u.ofdm.code_rate_LP; \
  130. (ch)->intlv_native = 1;
  131. #define INIT_OFDM_CHANNEL(ch) do {\
  132. (ch)->Bw = 0; \
  133. (ch)->nfft = -1; \
  134. (ch)->guard = -1; \
  135. (ch)->nqam = -1; \
  136. (ch)->vit_hrch = -1; \
  137. (ch)->vit_select_hp = -1; \
  138. (ch)->vit_alpha = -1; \
  139. (ch)->vit_code_rate_hp = -1; \
  140. (ch)->vit_code_rate_lp = -1; \
  141. } while (0)
  142. #endif