2 * FireDTV driver (formerly known as FireSAT)
4 * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com>
5 * Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se>
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of
10 * the License, or (at your option) any later version.
13 #include <linux/errno.h>
14 #include <linux/kernel.h>
15 #include <linux/types.h>
17 #include <dvb_frontend.h>
23 static int firesat_dvb_init(struct dvb_frontend *fe)
26 struct firesat *firesat = fe->sec_priv;
27 // printk("fdi: 1\n");
28 firesat->isochannel = firesat->adapter->num; //<< 1 | (firesat->subunit & 0x1); // ### ask IRM
29 // printk("fdi: 2\n");
30 result = try_CMPEstablishPPconnection(firesat, firesat->subunit, firesat->isochannel);
32 printk(KERN_ERR "Could not establish point to point "
36 // printk("fdi: 3\n");
38 result = setup_iso_channel(firesat);
39 // printk("fdi: 4. Result was %d\n", result);
43 static int firesat_sleep(struct dvb_frontend *fe)
45 struct firesat *firesat = fe->sec_priv;
47 tear_down_iso_channel(firesat);
48 try_CMPBreakPPconnection(firesat, firesat->subunit, firesat->isochannel);
49 firesat->isochannel = -1;
53 static int firesat_diseqc_send_master_cmd(struct dvb_frontend *fe,
54 struct dvb_diseqc_master_cmd *cmd)
56 struct firesat *firesat = fe->sec_priv;
58 return AVCLNBControl(firesat, LNBCONTROL_DONTCARE, LNBCONTROL_DONTCARE,
59 LNBCONTROL_DONTCARE, 1, cmd);
62 static int firesat_diseqc_send_burst(struct dvb_frontend *fe,
63 fe_sec_mini_cmd_t minicmd)
68 static int firesat_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
70 struct firesat *firesat = fe->sec_priv;
76 static int firesat_set_voltage(struct dvb_frontend *fe,
77 fe_sec_voltage_t voltage)
79 struct firesat *firesat = fe->sec_priv;
81 firesat->voltage = voltage;
85 static int firesat_read_status (struct dvb_frontend *fe, fe_status_t *status)
87 struct firesat *firesat = fe->sec_priv;
88 ANTENNA_INPUT_INFO info;
90 if (AVCTunerStatus(firesat, &info))
96 *status = FE_HAS_SIGNAL |
106 static int firesat_read_ber(struct dvb_frontend *fe, u32 *ber)
108 struct firesat *firesat = fe->sec_priv;
109 ANTENNA_INPUT_INFO info;
111 if (AVCTunerStatus(firesat, &info))
114 *ber = (info.BER[0] << 24) |
115 (info.BER[1] << 16) |
122 static int firesat_read_signal_strength (struct dvb_frontend *fe, u16 *strength)
124 struct firesat *firesat = fe->sec_priv;
125 ANTENNA_INPUT_INFO info;
127 if (AVCTunerStatus(firesat, &info))
130 *strength = info.SignalStrength << 8;
135 static int firesat_read_snr(struct dvb_frontend *fe, u16 *snr)
137 struct firesat *firesat = fe->sec_priv;
138 ANTENNA_INPUT_INFO info;
140 if (AVCTunerStatus(firesat, &info))
143 *snr = (info.CarrierNoiseRatio[0] << 8) +
144 info.CarrierNoiseRatio[1];
146 // C/N[dB] = -10 * log10(snr / 65535)
151 static int firesat_read_uncorrected_blocks(struct dvb_frontend *fe, u32 *ucblocks)
156 static int firesat_set_frontend(struct dvb_frontend *fe,
157 struct dvb_frontend_parameters *params)
159 struct firesat *firesat = fe->sec_priv;
161 if (AVCTuner_DSD(firesat, params, NULL) != ACCEPTED)
164 return 0; //not sure of this...
167 static int firesat_get_frontend(struct dvb_frontend *fe,
168 struct dvb_frontend_parameters *params)
173 static struct dvb_frontend_info firesat_S_frontend_info;
174 static struct dvb_frontend_info firesat_C_frontend_info;
175 static struct dvb_frontend_info firesat_T_frontend_info;
177 static struct dvb_frontend_ops firesat_ops = {
179 .init = firesat_dvb_init,
180 .sleep = firesat_sleep,
182 .set_frontend = firesat_set_frontend,
183 .get_frontend = firesat_get_frontend,
185 .read_status = firesat_read_status,
186 .read_ber = firesat_read_ber,
187 .read_signal_strength = firesat_read_signal_strength,
188 .read_snr = firesat_read_snr,
189 .read_ucblocks = firesat_read_uncorrected_blocks,
191 .diseqc_send_master_cmd = firesat_diseqc_send_master_cmd,
192 .diseqc_send_burst = firesat_diseqc_send_burst,
193 .set_tone = firesat_set_tone,
194 .set_voltage = firesat_set_voltage,
197 int firesat_frontend_attach(struct firesat *firesat, struct dvb_frontend *fe)
199 switch (firesat->type) {
201 firesat->frontend_info = &firesat_S_frontend_info;
204 firesat->frontend_info = &firesat_C_frontend_info;
207 firesat->frontend_info = &firesat_T_frontend_info;
210 printk(KERN_ERR "firedtv: no frontend for model type 0x%x\n",
212 firesat->frontend_info = NULL;
214 fe->ops = firesat_ops;
215 fe->ops.info = *(firesat->frontend_info);
216 fe->dvb = firesat->adapter;
221 static struct dvb_frontend_info firesat_S_frontend_info = {
223 .name = "FireDTV DVB-S Frontend",
226 .frequency_min = 950000,
227 .frequency_max = 2150000,
228 .frequency_stepsize = 125,
229 .symbol_rate_min = 1000000,
230 .symbol_rate_max = 40000000,
232 .caps = FE_CAN_INVERSION_AUTO |
242 static struct dvb_frontend_info firesat_C_frontend_info = {
244 .name = "FireDTV DVB-C Frontend",
247 .frequency_min = 47000000,
248 .frequency_max = 866000000,
249 .frequency_stepsize = 62500,
250 .symbol_rate_min = 870000,
251 .symbol_rate_max = 6900000,
253 .caps = FE_CAN_INVERSION_AUTO |
262 static struct dvb_frontend_info firesat_T_frontend_info = {
264 .name = "FireDTV DVB-T Frontend",
267 .frequency_min = 49000000,
268 .frequency_max = 861000000,
269 .frequency_stepsize = 62500,
271 .caps = FE_CAN_INVERSION_AUTO |
273 FE_CAN_TRANSMISSION_MODE_AUTO |
274 FE_CAN_GUARD_INTERVAL_AUTO |
275 FE_CAN_HIERARCHY_AUTO,