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 fdtv
->isochannel
= fdtv
->adapter
.num
;
30 err
= cmp_establish_pp_connection(fdtv
, fdtv
->subunit
,
34 "could not establish point to point connection\n");
38 return fdtv
->backend
->start_iso(fdtv
);
41 static int fdtv_sleep(struct dvb_frontend
*fe
)
43 struct firedtv
*fdtv
= fe
->sec_priv
;
45 fdtv
->backend
->stop_iso(fdtv
);
46 cmp_break_pp_connection(fdtv
, fdtv
->subunit
, fdtv
->isochannel
);
47 fdtv
->isochannel
= -1;
51 #define LNBCONTROL_DONTCARE 0xff
53 static int fdtv_diseqc_send_master_cmd(struct dvb_frontend
*fe
,
54 struct dvb_diseqc_master_cmd
*cmd
)
56 struct firedtv
*fdtv
= fe
->sec_priv
;
58 return avc_lnb_control(fdtv
, LNBCONTROL_DONTCARE
, LNBCONTROL_DONTCARE
,
59 LNBCONTROL_DONTCARE
, 1, cmd
);
62 static int fdtv_diseqc_send_burst(struct dvb_frontend
*fe
,
63 fe_sec_mini_cmd_t minicmd
)
68 static int fdtv_set_tone(struct dvb_frontend
*fe
, fe_sec_tone_mode_t tone
)
70 struct firedtv
*fdtv
= fe
->sec_priv
;
76 static int fdtv_set_voltage(struct dvb_frontend
*fe
,
77 fe_sec_voltage_t voltage
)
79 struct firedtv
*fdtv
= fe
->sec_priv
;
81 fdtv
->voltage
= voltage
;
85 static int fdtv_read_status(struct dvb_frontend
*fe
, fe_status_t
*status
)
87 struct firedtv
*fdtv
= fe
->sec_priv
;
88 struct firedtv_tuner_status stat
;
90 if (avc_tuner_status(fdtv
, &stat
))
96 *status
= FE_HAS_SIGNAL
| FE_HAS_VITERBI
| FE_HAS_SYNC
|
97 FE_HAS_CARRIER
| FE_HAS_LOCK
;
101 static int fdtv_read_ber(struct dvb_frontend
*fe
, u32
*ber
)
103 struct firedtv
*fdtv
= fe
->sec_priv
;
104 struct firedtv_tuner_status stat
;
106 if (avc_tuner_status(fdtv
, &stat
))
113 static int fdtv_read_signal_strength(struct dvb_frontend
*fe
, u16
*strength
)
115 struct firedtv
*fdtv
= fe
->sec_priv
;
116 struct firedtv_tuner_status stat
;
118 if (avc_tuner_status(fdtv
, &stat
))
121 *strength
= stat
.signal_strength
<< 8;
125 static int fdtv_read_snr(struct dvb_frontend
*fe
, u16
*snr
)
127 struct firedtv
*fdtv
= fe
->sec_priv
;
128 struct firedtv_tuner_status stat
;
130 if (avc_tuner_status(fdtv
, &stat
))
133 /* C/N[dB] = -10 * log10(snr / 65535) */
134 *snr
= stat
.carrier_noise_ratio
* 257;
138 static int fdtv_read_uncorrected_blocks(struct dvb_frontend
*fe
, u32
*ucblocks
)
143 static int fdtv_set_frontend(struct dvb_frontend
*fe
,
144 struct dvb_frontend_parameters
*params
)
146 struct firedtv
*fdtv
= fe
->sec_priv
;
148 return avc_tuner_dsd(fdtv
, params
);
151 static int fdtv_get_frontend(struct dvb_frontend
*fe
,
152 struct dvb_frontend_parameters
*params
)
157 void fdtv_frontend_init(struct firedtv
*fdtv
)
159 struct dvb_frontend_ops
*ops
= &fdtv
->fe
.ops
;
160 struct dvb_frontend_info
*fi
= &ops
->info
;
162 ops
->init
= fdtv_dvb_init
;
163 ops
->sleep
= fdtv_sleep
;
165 ops
->set_frontend
= fdtv_set_frontend
;
166 ops
->get_frontend
= fdtv_get_frontend
;
168 ops
->read_status
= fdtv_read_status
;
169 ops
->read_ber
= fdtv_read_ber
;
170 ops
->read_signal_strength
= fdtv_read_signal_strength
;
171 ops
->read_snr
= fdtv_read_snr
;
172 ops
->read_ucblocks
= fdtv_read_uncorrected_blocks
;
174 ops
->diseqc_send_master_cmd
= fdtv_diseqc_send_master_cmd
;
175 ops
->diseqc_send_burst
= fdtv_diseqc_send_burst
;
176 ops
->set_tone
= fdtv_set_tone
;
177 ops
->set_voltage
= fdtv_set_voltage
;
179 switch (fdtv
->type
) {
184 fi
->frequency_min
= 950000;
185 fi
->frequency_max
= 2150000;
186 fi
->frequency_stepsize
= 125;
187 fi
->symbol_rate_min
= 1000000;
188 fi
->symbol_rate_max
= 40000000;
190 fi
->caps
= FE_CAN_INVERSION_AUTO
|
203 fi
->frequency_min
= 47000000;
204 fi
->frequency_max
= 866000000;
205 fi
->frequency_stepsize
= 62500;
206 fi
->symbol_rate_min
= 870000;
207 fi
->symbol_rate_max
= 6900000;
209 fi
->caps
= FE_CAN_INVERSION_AUTO
|
221 fi
->frequency_min
= 49000000;
222 fi
->frequency_max
= 861000000;
223 fi
->frequency_stepsize
= 62500;
225 fi
->caps
= FE_CAN_INVERSION_AUTO
|
227 FE_CAN_TRANSMISSION_MODE_AUTO
|
228 FE_CAN_GUARD_INTERVAL_AUTO
|
229 FE_CAN_HIERARCHY_AUTO
;
233 dev_err(fdtv
->device
, "no frontend for model type %d\n",
236 strcpy(fi
->name
, fdtv_model_names
[fdtv
->type
]);
238 fdtv
->fe
.dvb
= &fdtv
->adapter
;
239 fdtv
->fe
.sec_priv
= fdtv
;