diff options
Diffstat (limited to 'drivers/media/dvb/firesat/firesat_fe.c')
-rw-r--r-- | drivers/media/dvb/firesat/firesat_fe.c | 223 |
1 files changed, 96 insertions, 127 deletions
diff --git a/drivers/media/dvb/firesat/firesat_fe.c b/drivers/media/dvb/firesat/firesat_fe.c index ec614ea8de22..1ed972b79573 100644 --- a/drivers/media/dvb/firesat/firesat_fe.c +++ b/drivers/media/dvb/firesat/firesat_fe.c | |||
@@ -12,6 +12,7 @@ | |||
12 | 12 | ||
13 | #include <linux/errno.h> | 13 | #include <linux/errno.h> |
14 | #include <linux/kernel.h> | 14 | #include <linux/kernel.h> |
15 | #include <linux/string.h> | ||
15 | #include <linux/types.h> | 16 | #include <linux/types.h> |
16 | 17 | ||
17 | #include <dvb_frontend.h> | 18 | #include <dvb_frontend.h> |
@@ -22,22 +23,21 @@ | |||
22 | 23 | ||
23 | static int firesat_dvb_init(struct dvb_frontend *fe) | 24 | static int firesat_dvb_init(struct dvb_frontend *fe) |
24 | { | 25 | { |
25 | int result; | ||
26 | struct firesat *firesat = fe->sec_priv; | 26 | struct firesat *firesat = fe->sec_priv; |
27 | // printk("fdi: 1\n"); | 27 | int err; |
28 | firesat->isochannel = firesat->adapter->num; //<< 1 | (firesat->subunit & 0x1); // ### ask IRM | 28 | |
29 | // printk("fdi: 2\n"); | 29 | /* FIXME - allocate free channel at IRM */ |
30 | result = try_CMPEstablishPPconnection(firesat, firesat->subunit, firesat->isochannel); | 30 | firesat->isochannel = firesat->adapter.num; |
31 | if (result != 0) { | 31 | |
32 | err = cmp_establish_pp_connection(firesat, firesat->subunit, | ||
33 | firesat->isochannel); | ||
34 | if (err) { | ||
32 | printk(KERN_ERR "Could not establish point to point " | 35 | printk(KERN_ERR "Could not establish point to point " |
33 | "connection.\n"); | 36 | "connection.\n"); |
34 | return -1; | 37 | return err; |
35 | } | 38 | } |
36 | // printk("fdi: 3\n"); | ||
37 | 39 | ||
38 | result = setup_iso_channel(firesat); | 40 | return setup_iso_channel(firesat); |
39 | // printk("fdi: 4. Result was %d\n", result); | ||
40 | return result; | ||
41 | } | 41 | } |
42 | 42 | ||
43 | static int firesat_sleep(struct dvb_frontend *fe) | 43 | static int firesat_sleep(struct dvb_frontend *fe) |
@@ -45,7 +45,7 @@ static int firesat_sleep(struct dvb_frontend *fe) | |||
45 | struct firesat *firesat = fe->sec_priv; | 45 | struct firesat *firesat = fe->sec_priv; |
46 | 46 | ||
47 | tear_down_iso_channel(firesat); | 47 | tear_down_iso_channel(firesat); |
48 | try_CMPBreakPPconnection(firesat, firesat->subunit, firesat->isochannel); | 48 | cmp_break_pp_connection(firesat, firesat->subunit, firesat->isochannel); |
49 | firesat->isochannel = -1; | 49 | firesat->isochannel = -1; |
50 | return 0; | 50 | return 0; |
51 | } | 51 | } |
@@ -55,8 +55,8 @@ static int firesat_diseqc_send_master_cmd(struct dvb_frontend *fe, | |||
55 | { | 55 | { |
56 | struct firesat *firesat = fe->sec_priv; | 56 | struct firesat *firesat = fe->sec_priv; |
57 | 57 | ||
58 | return AVCLNBControl(firesat, LNBCONTROL_DONTCARE, LNBCONTROL_DONTCARE, | 58 | return avc_lnb_control(firesat, LNBCONTROL_DONTCARE, |
59 | LNBCONTROL_DONTCARE, 1, cmd); | 59 | LNBCONTROL_DONTCARE, LNBCONTROL_DONTCARE, 1, cmd); |
60 | } | 60 | } |
61 | 61 | ||
62 | static int firesat_diseqc_send_burst(struct dvb_frontend *fe, | 62 | static int firesat_diseqc_send_burst(struct dvb_frontend *fe, |
@@ -82,24 +82,19 @@ static int firesat_set_voltage(struct dvb_frontend *fe, | |||
82 | return 0; | 82 | return 0; |
83 | } | 83 | } |
84 | 84 | ||
85 | static int firesat_read_status (struct dvb_frontend *fe, fe_status_t *status) | 85 | static int firesat_read_status(struct dvb_frontend *fe, fe_status_t *status) |
86 | { | 86 | { |
87 | struct firesat *firesat = fe->sec_priv; | 87 | struct firesat *firesat = fe->sec_priv; |
88 | ANTENNA_INPUT_INFO info; | 88 | ANTENNA_INPUT_INFO info; |
89 | 89 | ||
90 | if (AVCTunerStatus(firesat, &info)) | 90 | if (avc_tuner_status(firesat, &info)) |
91 | return -EINVAL; | 91 | return -EINVAL; |
92 | 92 | ||
93 | if (info.NoRF) { | 93 | if (info.NoRF) |
94 | *status = 0; | 94 | *status = 0; |
95 | } else { | 95 | else |
96 | *status = FE_HAS_SIGNAL | | 96 | *status = FE_HAS_SIGNAL | FE_HAS_VITERBI | FE_HAS_SYNC | |
97 | FE_HAS_VITERBI | | 97 | FE_HAS_CARRIER | FE_HAS_LOCK; |
98 | FE_HAS_SYNC | | ||
99 | FE_HAS_CARRIER | | ||
100 | FE_HAS_LOCK; | ||
101 | } | ||
102 | |||
103 | return 0; | 98 | return 0; |
104 | } | 99 | } |
105 | 100 | ||
@@ -108,14 +103,11 @@ static int firesat_read_ber(struct dvb_frontend *fe, u32 *ber) | |||
108 | struct firesat *firesat = fe->sec_priv; | 103 | struct firesat *firesat = fe->sec_priv; |
109 | ANTENNA_INPUT_INFO info; | 104 | ANTENNA_INPUT_INFO info; |
110 | 105 | ||
111 | if (AVCTunerStatus(firesat, &info)) | 106 | if (avc_tuner_status(firesat, &info)) |
112 | return -EINVAL; | 107 | return -EINVAL; |
113 | 108 | ||
114 | *ber = (info.BER[0] << 24) | | 109 | *ber = info.BER[0] << 24 | info.BER[1] << 16 | |
115 | (info.BER[1] << 16) | | 110 | info.BER[2] << 8 | info.BER[3]; |
116 | (info.BER[2] << 8) | | ||
117 | info.BER[3]; | ||
118 | |||
119 | return 0; | 111 | return 0; |
120 | } | 112 | } |
121 | 113 | ||
@@ -124,11 +116,10 @@ static int firesat_read_signal_strength (struct dvb_frontend *fe, u16 *strength) | |||
124 | struct firesat *firesat = fe->sec_priv; | 116 | struct firesat *firesat = fe->sec_priv; |
125 | ANTENNA_INPUT_INFO info; | 117 | ANTENNA_INPUT_INFO info; |
126 | 118 | ||
127 | if (AVCTunerStatus(firesat, &info)) | 119 | if (avc_tuner_status(firesat, &info)) |
128 | return -EINVAL; | 120 | return -EINVAL; |
129 | 121 | ||
130 | *strength = info.SignalStrength << 8; | 122 | *strength = info.SignalStrength << 8; |
131 | |||
132 | return 0; | 123 | return 0; |
133 | } | 124 | } |
134 | 125 | ||
@@ -137,14 +128,12 @@ static int firesat_read_snr(struct dvb_frontend *fe, u16 *snr) | |||
137 | struct firesat *firesat = fe->sec_priv; | 128 | struct firesat *firesat = fe->sec_priv; |
138 | ANTENNA_INPUT_INFO info; | 129 | ANTENNA_INPUT_INFO info; |
139 | 130 | ||
140 | if (AVCTunerStatus(firesat, &info)) | 131 | if (avc_tuner_status(firesat, &info)) |
141 | return -EINVAL; | 132 | return -EINVAL; |
142 | 133 | ||
143 | *snr = (info.CarrierNoiseRatio[0] << 8) + | 134 | /* C/N[dB] = -10 * log10(snr / 65535) */ |
144 | info.CarrierNoiseRatio[1]; | 135 | *snr = (info.CarrierNoiseRatio[0] << 8) + info.CarrierNoiseRatio[1]; |
145 | *snr *= 257; | 136 | *snr *= 257; |
146 | // C/N[dB] = -10 * log10(snr / 65535) | ||
147 | |||
148 | return 0; | 137 | return 0; |
149 | } | 138 | } |
150 | 139 | ||
@@ -158,10 +147,11 @@ static int firesat_set_frontend(struct dvb_frontend *fe, | |||
158 | { | 147 | { |
159 | struct firesat *firesat = fe->sec_priv; | 148 | struct firesat *firesat = fe->sec_priv; |
160 | 149 | ||
161 | if (AVCTuner_DSD(firesat, params, NULL) != ACCEPTED) | 150 | /* FIXME: avc_tuner_dsd never returns ACCEPTED. Check status? */ |
151 | if (avc_tuner_dsd(firesat, params) != ACCEPTED) | ||
162 | return -EINVAL; | 152 | return -EINVAL; |
163 | else | 153 | else |
164 | return 0; //not sure of this... | 154 | return 0; /* not sure of this... */ |
165 | } | 155 | } |
166 | 156 | ||
167 | static int firesat_get_frontend(struct dvb_frontend *fe, | 157 | static int firesat_get_frontend(struct dvb_frontend *fe, |
@@ -170,107 +160,86 @@ static int firesat_get_frontend(struct dvb_frontend *fe, | |||
170 | return -EOPNOTSUPP; | 160 | return -EOPNOTSUPP; |
171 | } | 161 | } |
172 | 162 | ||
173 | static struct dvb_frontend_info firesat_S_frontend_info; | 163 | void firesat_frontend_init(struct firesat *firesat) |
174 | static struct dvb_frontend_info firesat_C_frontend_info; | 164 | { |
175 | static struct dvb_frontend_info firesat_T_frontend_info; | 165 | struct dvb_frontend_ops *ops = &firesat->fe.ops; |
176 | 166 | struct dvb_frontend_info *fi = &ops->info; | |
177 | static struct dvb_frontend_ops firesat_ops = { | ||
178 | 167 | ||
179 | .init = firesat_dvb_init, | 168 | ops->init = firesat_dvb_init; |
180 | .sleep = firesat_sleep, | 169 | ops->sleep = firesat_sleep; |
181 | 170 | ||
182 | .set_frontend = firesat_set_frontend, | 171 | ops->set_frontend = firesat_set_frontend; |
183 | .get_frontend = firesat_get_frontend, | 172 | ops->get_frontend = firesat_get_frontend; |
184 | 173 | ||
185 | .read_status = firesat_read_status, | 174 | ops->read_status = firesat_read_status; |
186 | .read_ber = firesat_read_ber, | 175 | ops->read_ber = firesat_read_ber; |
187 | .read_signal_strength = firesat_read_signal_strength, | 176 | ops->read_signal_strength = firesat_read_signal_strength; |
188 | .read_snr = firesat_read_snr, | 177 | ops->read_snr = firesat_read_snr; |
189 | .read_ucblocks = firesat_read_uncorrected_blocks, | 178 | ops->read_ucblocks = firesat_read_uncorrected_blocks; |
190 | 179 | ||
191 | .diseqc_send_master_cmd = firesat_diseqc_send_master_cmd, | 180 | ops->diseqc_send_master_cmd = firesat_diseqc_send_master_cmd; |
192 | .diseqc_send_burst = firesat_diseqc_send_burst, | 181 | ops->diseqc_send_burst = firesat_diseqc_send_burst; |
193 | .set_tone = firesat_set_tone, | 182 | ops->set_tone = firesat_set_tone; |
194 | .set_voltage = firesat_set_voltage, | 183 | ops->set_voltage = firesat_set_voltage; |
195 | }; | ||
196 | 184 | ||
197 | int firesat_frontend_attach(struct firesat *firesat, struct dvb_frontend *fe) | ||
198 | { | ||
199 | switch (firesat->type) { | 185 | switch (firesat->type) { |
200 | case FireSAT_DVB_S: | 186 | case FireSAT_DVB_S: |
201 | firesat->frontend_info = &firesat_S_frontend_info; | 187 | fi->type = FE_QPSK; |
188 | |||
189 | fi->frequency_min = 950000; | ||
190 | fi->frequency_max = 2150000; | ||
191 | fi->frequency_stepsize = 125; | ||
192 | fi->symbol_rate_min = 1000000; | ||
193 | fi->symbol_rate_max = 40000000; | ||
194 | |||
195 | fi->caps = FE_CAN_INVERSION_AUTO | | ||
196 | FE_CAN_FEC_1_2 | | ||
197 | FE_CAN_FEC_2_3 | | ||
198 | FE_CAN_FEC_3_4 | | ||
199 | FE_CAN_FEC_5_6 | | ||
200 | FE_CAN_FEC_7_8 | | ||
201 | FE_CAN_FEC_AUTO | | ||
202 | FE_CAN_QPSK; | ||
202 | break; | 203 | break; |
204 | |||
203 | case FireSAT_DVB_C: | 205 | case FireSAT_DVB_C: |
204 | firesat->frontend_info = &firesat_C_frontend_info; | 206 | fi->type = FE_QAM; |
207 | |||
208 | fi->frequency_min = 47000000; | ||
209 | fi->frequency_max = 866000000; | ||
210 | fi->frequency_stepsize = 62500; | ||
211 | fi->symbol_rate_min = 870000; | ||
212 | fi->symbol_rate_max = 6900000; | ||
213 | |||
214 | fi->caps = FE_CAN_INVERSION_AUTO | | ||
215 | FE_CAN_QAM_16 | | ||
216 | FE_CAN_QAM_32 | | ||
217 | FE_CAN_QAM_64 | | ||
218 | FE_CAN_QAM_128 | | ||
219 | FE_CAN_QAM_256 | | ||
220 | FE_CAN_QAM_AUTO; | ||
205 | break; | 221 | break; |
222 | |||
206 | case FireSAT_DVB_T: | 223 | case FireSAT_DVB_T: |
207 | firesat->frontend_info = &firesat_T_frontend_info; | 224 | fi->type = FE_OFDM; |
225 | |||
226 | fi->frequency_min = 49000000; | ||
227 | fi->frequency_max = 861000000; | ||
228 | fi->frequency_stepsize = 62500; | ||
229 | |||
230 | fi->caps = FE_CAN_INVERSION_AUTO | | ||
231 | FE_CAN_FEC_2_3 | | ||
232 | FE_CAN_TRANSMISSION_MODE_AUTO | | ||
233 | FE_CAN_GUARD_INTERVAL_AUTO | | ||
234 | FE_CAN_HIERARCHY_AUTO; | ||
208 | break; | 235 | break; |
236 | |||
209 | default: | 237 | default: |
210 | printk(KERN_ERR "firedtv: no frontend for model type 0x%x\n", | 238 | printk(KERN_ERR "FireDTV: no frontend for model type %d\n", |
211 | firesat->type); | 239 | firesat->type); |
212 | firesat->frontend_info = NULL; | ||
213 | } | 240 | } |
214 | fe->ops = firesat_ops; | 241 | strcpy(fi->name, firedtv_model_names[firesat->type]); |
215 | fe->ops.info = *(firesat->frontend_info); | ||
216 | fe->dvb = firesat->adapter; | ||
217 | 242 | ||
218 | return 0; | 243 | firesat->fe.dvb = &firesat->adapter; |
244 | firesat->fe.sec_priv = firesat; | ||
219 | } | 245 | } |
220 | |||
221 | static struct dvb_frontend_info firesat_S_frontend_info = { | ||
222 | |||
223 | .name = "FireDTV DVB-S Frontend", | ||
224 | .type = FE_QPSK, | ||
225 | |||
226 | .frequency_min = 950000, | ||
227 | .frequency_max = 2150000, | ||
228 | .frequency_stepsize = 125, | ||
229 | .symbol_rate_min = 1000000, | ||
230 | .symbol_rate_max = 40000000, | ||
231 | |||
232 | .caps = FE_CAN_INVERSION_AUTO | | ||
233 | FE_CAN_FEC_1_2 | | ||
234 | FE_CAN_FEC_2_3 | | ||
235 | FE_CAN_FEC_3_4 | | ||
236 | FE_CAN_FEC_5_6 | | ||
237 | FE_CAN_FEC_7_8 | | ||
238 | FE_CAN_FEC_AUTO | | ||
239 | FE_CAN_QPSK, | ||
240 | }; | ||
241 | |||
242 | static struct dvb_frontend_info firesat_C_frontend_info = { | ||
243 | |||
244 | .name = "FireDTV DVB-C Frontend", | ||
245 | .type = FE_QAM, | ||
246 | |||
247 | .frequency_min = 47000000, | ||
248 | .frequency_max = 866000000, | ||
249 | .frequency_stepsize = 62500, | ||
250 | .symbol_rate_min = 870000, | ||
251 | .symbol_rate_max = 6900000, | ||
252 | |||
253 | .caps = FE_CAN_INVERSION_AUTO | | ||
254 | FE_CAN_QAM_16 | | ||
255 | FE_CAN_QAM_32 | | ||
256 | FE_CAN_QAM_64 | | ||
257 | FE_CAN_QAM_128 | | ||
258 | FE_CAN_QAM_256 | | ||
259 | FE_CAN_QAM_AUTO, | ||
260 | }; | ||
261 | |||
262 | static struct dvb_frontend_info firesat_T_frontend_info = { | ||
263 | |||
264 | .name = "FireDTV DVB-T Frontend", | ||
265 | .type = FE_OFDM, | ||
266 | |||
267 | .frequency_min = 49000000, | ||
268 | .frequency_max = 861000000, | ||
269 | .frequency_stepsize = 62500, | ||
270 | |||
271 | .caps = FE_CAN_INVERSION_AUTO | | ||
272 | FE_CAN_FEC_2_3 | | ||
273 | FE_CAN_TRANSMISSION_MODE_AUTO | | ||
274 | FE_CAN_GUARD_INTERVAL_AUTO | | ||
275 | FE_CAN_HIERARCHY_AUTO, | ||
276 | }; | ||