blob: 4f5d141a308dc45945a762db1a4433fd93086c8a [file] [log] [blame]
Patrick Boettcher42afd062006-07-29 17:33:44 -03001#ifndef DIBX000_COMMON_H
2#define DIBX000_COMMON_H
3
4enum dibx000_i2c_interface {
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -03005 DIBX000_I2C_INTERFACE_TUNER = 0,
Patrick Boettcher42afd062006-07-29 17:33:44 -03006 DIBX000_I2C_INTERFACE_GPIO_1_2 = 1,
7 DIBX000_I2C_INTERFACE_GPIO_3_4 = 2
8};
9
10struct dibx000_i2c_master {
11#define DIB3000MC 1
12#define DIB7000 2
13#define DIB7000P 11
14#define DIB7000MC 12
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -030015#define DIB8000 13
Patrick Boettcher42afd062006-07-29 17:33:44 -030016 u16 device_rev;
17
18 enum dibx000_i2c_interface selected_interface;
19
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -030020// struct i2c_adapter tuner_i2c_adap;
21 struct i2c_adapter gated_tuner_i2c_adap;
Patrick Boettcher42afd062006-07-29 17:33:44 -030022
23 struct i2c_adapter *i2c_adap;
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -030024 u8 i2c_addr;
Patrick Boettcher42afd062006-07-29 17:33:44 -030025
26 u16 base_reg;
27};
28
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -030029extern int dibx000_init_i2c_master(struct dibx000_i2c_master *mst,
30 u16 device_rev, struct i2c_adapter *i2c_adap,
31 u8 i2c_addr);
32extern struct i2c_adapter *dibx000_get_i2c_adapter(struct dibx000_i2c_master
33 *mst,
34 enum dibx000_i2c_interface
35 intf, int gating);
Patrick Boettcher42afd062006-07-29 17:33:44 -030036extern void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst);
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -030037extern void dibx000_reset_i2c_master(struct dibx000_i2c_master *mst);
Patrick Boettcher42afd062006-07-29 17:33:44 -030038
Olivier Grenie03245a52009-12-04 13:27:57 -030039extern u32 systime(void);
40
Patrick Boettcher42afd062006-07-29 17:33:44 -030041#define BAND_LBAND 0x01
42#define BAND_UHF 0x02
43#define BAND_VHF 0x04
Patrick Boettcher69ea31e2006-10-17 18:28:14 -030044#define BAND_SBAND 0x08
Olivier Grenie03245a52009-12-04 13:27:57 -030045#define BAND_FM 0x10
46#define BAND_CBAND 0x20
Patrick Boettcher69ea31e2006-10-17 18:28:14 -030047
Olivier Grenie9c783032009-12-07 07:49:40 -030048#define BAND_OF_FREQUENCY(freq_kHz) ((freq_kHz) <= 170000 ? BAND_CBAND : \
Olivier Grenie03245a52009-12-04 13:27:57 -030049 (freq_kHz) <= 115000 ? BAND_FM : \
Patrick Boettcher69ea31e2006-10-17 18:28:14 -030050 (freq_kHz) <= 250000 ? BAND_VHF : \
51 (freq_kHz) <= 863000 ? BAND_UHF : \
52 (freq_kHz) <= 2000000 ? BAND_LBAND : BAND_SBAND )
Patrick Boettcher42afd062006-07-29 17:33:44 -030053
54struct dibx000_agc_config {
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -030055 /* defines the capabilities of this AGC-setting - using the BAND_-defines */
56 u8 band_caps;
Patrick Boettcher42afd062006-07-29 17:33:44 -030057
58 u16 setup;
59
60 u16 inv_gain;
61 u16 time_stabiliz;
62
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -030063 u8 alpha_level;
Patrick Boettcher42afd062006-07-29 17:33:44 -030064 u16 thlock;
65
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -030066 u8 wbd_inv;
Patrick Boettcher42afd062006-07-29 17:33:44 -030067 u16 wbd_ref;
68 u8 wbd_sel;
69 u8 wbd_alpha;
70
71 u16 agc1_max;
72 u16 agc1_min;
73 u16 agc2_max;
74 u16 agc2_min;
75
76 u8 agc1_pt1;
77 u8 agc1_pt2;
78 u8 agc1_pt3;
79
80 u8 agc1_slope1;
81 u8 agc1_slope2;
82
83 u8 agc2_pt1;
84 u8 agc2_pt2;
85
86 u8 agc2_slope1;
87 u8 agc2_slope2;
88
89 u8 alpha_mant;
90 u8 alpha_exp;
91
92 u8 beta_mant;
93 u8 beta_exp;
94
95 u8 perform_agc_softsplit;
96
97 struct {
98 u16 min;
99 u16 max;
100 u16 min_thres;
101 u16 max_thres;
102 } split;
103};
104
105struct dibx000_bandwidth_config {
Patrick Boettcher77e2c0f2009-08-17 07:01:10 -0300106 u32 internal;
107 u32 sampling;
Patrick Boettcher42afd062006-07-29 17:33:44 -0300108
109 u8 pll_prediv;
110 u8 pll_ratio;
111 u8 pll_range;
112 u8 pll_reset;
113 u8 pll_bypass;
114
115 u8 enable_refdiv;
116 u8 bypclk_div;
117 u8 IO_CLK_en_core;
118 u8 ADClkSrc;
119 u8 modulo;
120
121 u16 sad_cfg;
122
123 u32 ifreq;
124 u32 timf;
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300125
126 u32 xtal_hz;
Patrick Boettcher42afd062006-07-29 17:33:44 -0300127};
128
129enum dibx000_adc_states {
130 DIBX000_SLOW_ADC_ON = 0,
131 DIBX000_SLOW_ADC_OFF,
132 DIBX000_ADC_ON,
133 DIBX000_ADC_OFF,
134 DIBX000_VBG_ENABLE,
135 DIBX000_VBG_DISABLE,
136};
137
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300138#define BANDWIDTH_TO_KHZ(v) ( (v) == BANDWIDTH_8_MHZ ? 8000 : \
Patrick Boettcher42afd062006-07-29 17:33:44 -0300139 (v) == BANDWIDTH_7_MHZ ? 7000 : \
140 (v) == BANDWIDTH_6_MHZ ? 6000 : 8000 )
141
Patrick Boettcher904a82e2008-01-25 07:31:58 -0300142#define BANDWIDTH_TO_INDEX(v) ( \
143 (v) == 8000 ? BANDWIDTH_8_MHZ : \
144 (v) == 7000 ? BANDWIDTH_7_MHZ : \
145 (v) == 6000 ? BANDWIDTH_6_MHZ : BANDWIDTH_8_MHZ )
146
Patrick Boettcher42afd062006-07-29 17:33:44 -0300147/* Chip output mode. */
Patrick Boettcherb6884a12007-07-27 10:08:51 -0300148#define OUTMODE_HIGH_Z 0
149#define OUTMODE_MPEG2_PAR_GATED_CLK 1
150#define OUTMODE_MPEG2_PAR_CONT_CLK 2
151#define OUTMODE_MPEG2_SERIAL 7
152#define OUTMODE_DIVERSITY 4
153#define OUTMODE_MPEG2_FIFO 5
154#define OUTMODE_ANALOG_ADC 6
Patrick Boettcher42afd062006-07-29 17:33:44 -0300155
Olivier Grenie03245a52009-12-04 13:27:57 -0300156enum frontend_tune_state {
157 CT_TUNER_START = 10,
158 CT_TUNER_STEP_0,
159 CT_TUNER_STEP_1,
160 CT_TUNER_STEP_2,
161 CT_TUNER_STEP_3,
162 CT_TUNER_STEP_4,
163 CT_TUNER_STEP_5,
164 CT_TUNER_STEP_6,
165 CT_TUNER_STEP_7,
166 CT_TUNER_STOP,
167
168 CT_AGC_START = 20,
169 CT_AGC_STEP_0,
170 CT_AGC_STEP_1,
171 CT_AGC_STEP_2,
172 CT_AGC_STEP_3,
173 CT_AGC_STEP_4,
174 CT_AGC_STOP,
175
176 CT_DEMOD_START = 30,
177 CT_DEMOD_STEP_1,
178 CT_DEMOD_STEP_2,
179 CT_DEMOD_STEP_3,
180 CT_DEMOD_STEP_4,
181 CT_DEMOD_STEP_5,
182 CT_DEMOD_STEP_6,
183 CT_DEMOD_STEP_7,
184 CT_DEMOD_STEP_8,
185 CT_DEMOD_STEP_9,
186 CT_DEMOD_STEP_10,
187 CT_DEMOD_SEARCH_NEXT = 41,
188 CT_DEMOD_STEP_LOCKED,
189 CT_DEMOD_STOP,
190
191 CT_DONE = 100,
192 CT_SHUTDOWN,
193
194};
195
196struct dvb_frontend_parametersContext {
197#define CHANNEL_STATUS_PARAMETERS_UNKNOWN 0x01
198#define CHANNEL_STATUS_PARAMETERS_SET 0x02
199 u8 status;
200 u32 tune_time_estimation[2];
201 s32 tps_available;
202 u16 tps[9];
203};
204
205#define FE_STATUS_TUNE_FAILED 0
206#define FE_STATUS_TUNE_TIMED_OUT -1
207#define FE_STATUS_TUNE_TIME_TOO_SHORT -2
208#define FE_STATUS_TUNE_PENDING -3
209#define FE_STATUS_STD_SUCCESS -4
210#define FE_STATUS_FFT_SUCCESS -5
211#define FE_STATUS_DEMOD_SUCCESS -6
212#define FE_STATUS_LOCKED -7
213#define FE_STATUS_DATA_LOCKED -8
214
215#define FE_CALLBACK_TIME_NEVER 0xffffffff
216
Olivier Grenie9c783032009-12-07 07:49:40 -0300217#define ABS(x) ((x < 0) ? (-x) : (x))
Olivier Grenie03245a52009-12-04 13:27:57 -0300218
Patrick Boettcher42afd062006-07-29 17:33:44 -0300219#endif