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/string.h>
16 #include <linux/types.h>
18 #include <dvb_frontend.h>
24 static int firesat_dvb_init(struct dvb_frontend *fe)
26 struct firesat *firesat = fe->sec_priv;
29 /* FIXME - allocate free channel at IRM */
30 firesat->isochannel = firesat->adapter.num;
32 err = cmp_establish_pp_connection(firesat, firesat->subunit,
35 printk(KERN_ERR "Could not establish point to point "
40 return setup_iso_channel(firesat);
43 static int firesat_sleep(struct dvb_frontend *fe)
45 struct firesat *firesat = fe->sec_priv;
47 tear_down_iso_channel(firesat);
48 cmp_break_pp_connection(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 avc_lnb_control(firesat, LNBCONTROL_DONTCARE,
59 LNBCONTROL_DONTCARE, 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 (avc_tuner_status(firesat, &info))
96 *status = FE_HAS_SIGNAL | FE_HAS_VITERBI | FE_HAS_SYNC |
97 FE_HAS_CARRIER | FE_HAS_LOCK;
101 static int firesat_read_ber(struct dvb_frontend *fe, u32 *ber)
103 struct firesat *firesat = fe->sec_priv;
104 ANTENNA_INPUT_INFO info;
106 if (avc_tuner_status(firesat, &info))
109 *ber = info.BER[0] << 24 | info.BER[1] << 16 |
110 info.BER[2] << 8 | info.BER[3];
114 static int firesat_read_signal_strength (struct dvb_frontend *fe, u16 *strength)
116 struct firesat *firesat = fe->sec_priv;
117 ANTENNA_INPUT_INFO info;
119 if (avc_tuner_status(firesat, &info))
122 *strength = info.SignalStrength << 8;
126 static int firesat_read_snr(struct dvb_frontend *fe, u16 *snr)
128 struct firesat *firesat = fe->sec_priv;
129 ANTENNA_INPUT_INFO info;
131 if (avc_tuner_status(firesat, &info))
134 /* C/N[dB] = -10 * log10(snr / 65535) */
135 *snr = (info.CarrierNoiseRatio[0] << 8) + info.CarrierNoiseRatio[1];
140 static int firesat_read_uncorrected_blocks(struct dvb_frontend *fe, u32 *ucblocks)
145 static int firesat_set_frontend(struct dvb_frontend *fe,
146 struct dvb_frontend_parameters *params)
148 struct firesat *firesat = fe->sec_priv;
150 /* FIXME: avc_tuner_dsd never returns ACCEPTED. Check status? */
151 if (avc_tuner_dsd(firesat, params) != ACCEPTED)
154 return 0; /* not sure of this... */
157 static int firesat_get_frontend(struct dvb_frontend *fe,
158 struct dvb_frontend_parameters *params)
163 void firesat_frontend_init(struct firesat *firesat)
165 struct dvb_frontend_ops *ops = &firesat->fe.ops;
166 struct dvb_frontend_info *fi = &ops->info;
168 ops->init = firesat_dvb_init;
169 ops->sleep = firesat_sleep;
171 ops->set_frontend = firesat_set_frontend;
172 ops->get_frontend = firesat_get_frontend;
174 ops->read_status = firesat_read_status;
175 ops->read_ber = firesat_read_ber;
176 ops->read_signal_strength = firesat_read_signal_strength;
177 ops->read_snr = firesat_read_snr;
178 ops->read_ucblocks = firesat_read_uncorrected_blocks;
180 ops->diseqc_send_master_cmd = firesat_diseqc_send_master_cmd;
181 ops->diseqc_send_burst = firesat_diseqc_send_burst;
182 ops->set_tone = firesat_set_tone;
183 ops->set_voltage = firesat_set_voltage;
185 switch (firesat->type) {
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;
195 fi->caps = FE_CAN_INVERSION_AUTO |
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;
214 fi->caps = FE_CAN_INVERSION_AUTO |
226 fi->frequency_min = 49000000;
227 fi->frequency_max = 861000000;
228 fi->frequency_stepsize = 62500;
230 fi->caps = FE_CAN_INVERSION_AUTO |
232 FE_CAN_TRANSMISSION_MODE_AUTO |
233 FE_CAN_GUARD_INTERVAL_AUTO |
234 FE_CAN_HIERARCHY_AUTO;
238 printk(KERN_ERR "FireDTV: no frontend for model type %d\n",
241 strcpy(fi->name, firedtv_model_names[firesat->type]);
243 firesat->fe.dvb = &firesat->adapter;
244 firesat->fe.sec_priv = firesat;