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/device.h>
14 #include <linux/errno.h>
15 #include <linux/kernel.h>
16 #include <linux/string.h>
17 #include <linux/types.h>
19 #include <dvb_frontend.h>
23 static int fdtv_dvb_init(struct dvb_frontend
*fe
)
25 struct firedtv
*fdtv
= fe
->sec_priv
;
28 /* FIXME - allocate free channel at IRM */
29 fdtv
->isochannel
= fdtv
->adapter
.num
;
31 err
= cmp_establish_pp_connection(fdtv
, fdtv
->subunit
,
35 "could not establish point to point connection\n");
39 return fdtv_start_iso(fdtv
);
42 static int fdtv_sleep(struct dvb_frontend
*fe
)
44 struct firedtv
*fdtv
= fe
->sec_priv
;
47 cmp_break_pp_connection(fdtv
, fdtv
->subunit
, fdtv
->isochannel
);
48 fdtv
->isochannel
= -1;
52 #define LNBCONTROL_DONTCARE 0xff
54 static int fdtv_diseqc_send_master_cmd(struct dvb_frontend
*fe
,
55 struct dvb_diseqc_master_cmd
*cmd
)
57 struct firedtv
*fdtv
= fe
->sec_priv
;
59 return avc_lnb_control(fdtv
, LNBCONTROL_DONTCARE
, LNBCONTROL_DONTCARE
,
60 LNBCONTROL_DONTCARE
, 1, cmd
);
63 static int fdtv_diseqc_send_burst(struct dvb_frontend
*fe
,
64 fe_sec_mini_cmd_t minicmd
)
69 static int fdtv_set_tone(struct dvb_frontend
*fe
, fe_sec_tone_mode_t tone
)
71 struct firedtv
*fdtv
= fe
->sec_priv
;
77 static int fdtv_set_voltage(struct dvb_frontend
*fe
,
78 fe_sec_voltage_t voltage
)
80 struct firedtv
*fdtv
= fe
->sec_priv
;
82 fdtv
->voltage
= voltage
;
86 static int fdtv_read_status(struct dvb_frontend
*fe
, fe_status_t
*status
)
88 struct firedtv
*fdtv
= fe
->sec_priv
;
89 struct firedtv_tuner_status stat
;
91 if (avc_tuner_status(fdtv
, &stat
))
97 *status
= FE_HAS_SIGNAL
| FE_HAS_VITERBI
| FE_HAS_SYNC
|
98 FE_HAS_CARRIER
| FE_HAS_LOCK
;
102 static int fdtv_read_ber(struct dvb_frontend
*fe
, u32
*ber
)
104 struct firedtv
*fdtv
= fe
->sec_priv
;
105 struct firedtv_tuner_status stat
;
107 if (avc_tuner_status(fdtv
, &stat
))
114 static int fdtv_read_signal_strength(struct dvb_frontend
*fe
, u16
*strength
)
116 struct firedtv
*fdtv
= fe
->sec_priv
;
117 struct firedtv_tuner_status stat
;
119 if (avc_tuner_status(fdtv
, &stat
))
122 *strength
= stat
.signal_strength
<< 8;
126 static int fdtv_read_snr(struct dvb_frontend
*fe
, u16
*snr
)
128 struct firedtv
*fdtv
= fe
->sec_priv
;
129 struct firedtv_tuner_status stat
;
131 if (avc_tuner_status(fdtv
, &stat
))
134 /* C/N[dB] = -10 * log10(snr / 65535) */
135 *snr
= stat
.carrier_noise_ratio
* 257;
139 static int fdtv_read_uncorrected_blocks(struct dvb_frontend
*fe
, u32
*ucblocks
)
144 static int fdtv_set_frontend(struct dvb_frontend
*fe
,
145 struct dvb_frontend_parameters
*params
)
147 struct firedtv
*fdtv
= fe
->sec_priv
;
149 return avc_tuner_dsd(fdtv
, params
);
152 static int fdtv_get_frontend(struct dvb_frontend
*fe
,
153 struct dvb_frontend_parameters
*params
)
158 static int fdtv_get_property(struct dvb_frontend
*fe
, struct dtv_property
*tvp
)
163 static int fdtv_set_property(struct dvb_frontend
*fe
, struct dtv_property
*tvp
)
168 void fdtv_frontend_init(struct firedtv
*fdtv
, const char *name
)
170 struct dvb_frontend_ops
*ops
= &fdtv
->fe
.ops
;
171 struct dvb_frontend_info
*fi
= &ops
->info
;
173 ops
->init
= fdtv_dvb_init
;
174 ops
->sleep
= fdtv_sleep
;
176 ops
->set_frontend
= fdtv_set_frontend
;
177 ops
->get_frontend
= fdtv_get_frontend
;
179 ops
->get_property
= fdtv_get_property
;
180 ops
->set_property
= fdtv_set_property
;
182 ops
->read_status
= fdtv_read_status
;
183 ops
->read_ber
= fdtv_read_ber
;
184 ops
->read_signal_strength
= fdtv_read_signal_strength
;
185 ops
->read_snr
= fdtv_read_snr
;
186 ops
->read_ucblocks
= fdtv_read_uncorrected_blocks
;
188 ops
->diseqc_send_master_cmd
= fdtv_diseqc_send_master_cmd
;
189 ops
->diseqc_send_burst
= fdtv_diseqc_send_burst
;
190 ops
->set_tone
= fdtv_set_tone
;
191 ops
->set_voltage
= fdtv_set_voltage
;
193 switch (fdtv
->type
) {
197 fi
->frequency_min
= 950000;
198 fi
->frequency_max
= 2150000;
199 fi
->frequency_stepsize
= 125;
200 fi
->symbol_rate_min
= 1000000;
201 fi
->symbol_rate_max
= 40000000;
203 fi
->caps
= FE_CAN_INVERSION_AUTO
|
216 fi
->frequency_min
= 950000;
217 fi
->frequency_max
= 2150000;
218 fi
->frequency_stepsize
= 125;
219 fi
->symbol_rate_min
= 1000000;
220 fi
->symbol_rate_max
= 40000000;
222 fi
->caps
= FE_CAN_INVERSION_AUTO
|
230 FE_CAN_2G_MODULATION
;
236 fi
->frequency_min
= 47000000;
237 fi
->frequency_max
= 866000000;
238 fi
->frequency_stepsize
= 62500;
239 fi
->symbol_rate_min
= 870000;
240 fi
->symbol_rate_max
= 6900000;
242 fi
->caps
= FE_CAN_INVERSION_AUTO
|
254 fi
->frequency_min
= 49000000;
255 fi
->frequency_max
= 861000000;
256 fi
->frequency_stepsize
= 62500;
258 fi
->caps
= FE_CAN_INVERSION_AUTO
|
260 FE_CAN_TRANSMISSION_MODE_AUTO
|
261 FE_CAN_GUARD_INTERVAL_AUTO
|
262 FE_CAN_HIERARCHY_AUTO
;
266 dev_err(fdtv
->device
, "no frontend for model type %d\n",
269 strcpy(fi
->name
, name
);
271 fdtv
->fe
.dvb
= &fdtv
->adapter
;
272 fdtv
->fe
.sec_priv
= fdtv
;