]>
Commit | Line | Data |
---|---|---|
df4846c3 | 1 | /* |
612262a5 | 2 | * FireDTV driver (formerly known as FireSAT) |
df4846c3 | 3 | * |
612262a5 SR |
4 | * Copyright (C) 2004 Andreas Monitzer <andy@monitzer.com> |
5 | * Copyright (C) 2008 Henrik Kurelid <henrik@kurelid.se> | |
df4846c3 HK |
6 | * |
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. | |
11 | */ | |
12 | ||
15490795 | 13 | #include <linux/device.h> |
c81c8b68 | 14 | #include <linux/errno.h> |
612262a5 | 15 | #include <linux/kernel.h> |
8ae83cdf | 16 | #include <linux/string.h> |
612262a5 SR |
17 | #include <linux/types.h> |
18 | ||
19 | #include <dvb_frontend.h> | |
c81c8b68 | 20 | |
a70f81c1 | 21 | #include "firedtv.h" |
c81c8b68 | 22 | |
a70f81c1 | 23 | static int fdtv_dvb_init(struct dvb_frontend *fe) |
c81c8b68 | 24 | { |
a70f81c1 | 25 | struct firedtv *fdtv = fe->sec_priv; |
8ae83cdf SR |
26 | int err; |
27 | ||
28 | /* FIXME - allocate free channel at IRM */ | |
a70f81c1 | 29 | fdtv->isochannel = fdtv->adapter.num; |
8ae83cdf | 30 | |
a70f81c1 R |
31 | err = cmp_establish_pp_connection(fdtv, fdtv->subunit, |
32 | fdtv->isochannel); | |
8ae83cdf | 33 | if (err) { |
15490795 SR |
34 | dev_err(fdtv->device, |
35 | "could not establish point to point connection\n"); | |
8ae83cdf | 36 | return err; |
df4846c3 | 37 | } |
df4846c3 | 38 | |
15490795 | 39 | return fdtv->backend->start_iso(fdtv); |
c81c8b68 GKH |
40 | } |
41 | ||
a70f81c1 | 42 | static int fdtv_sleep(struct dvb_frontend *fe) |
c81c8b68 | 43 | { |
a70f81c1 | 44 | struct firedtv *fdtv = fe->sec_priv; |
c81c8b68 | 45 | |
15490795 | 46 | fdtv->backend->stop_iso(fdtv); |
a70f81c1 R |
47 | cmp_break_pp_connection(fdtv, fdtv->subunit, fdtv->isochannel); |
48 | fdtv->isochannel = -1; | |
c81c8b68 GKH |
49 | return 0; |
50 | } | |
51 | ||
15490795 SR |
52 | #define LNBCONTROL_DONTCARE 0xff |
53 | ||
a70f81c1 | 54 | static int fdtv_diseqc_send_master_cmd(struct dvb_frontend *fe, |
15490795 | 55 | struct dvb_diseqc_master_cmd *cmd) |
c81c8b68 | 56 | { |
a70f81c1 | 57 | struct firedtv *fdtv = fe->sec_priv; |
c81c8b68 | 58 | |
15490795 SR |
59 | return avc_lnb_control(fdtv, LNBCONTROL_DONTCARE, LNBCONTROL_DONTCARE, |
60 | LNBCONTROL_DONTCARE, 1, cmd); | |
c81c8b68 GKH |
61 | } |
62 | ||
a70f81c1 | 63 | static int fdtv_diseqc_send_burst(struct dvb_frontend *fe, |
15490795 | 64 | fe_sec_mini_cmd_t minicmd) |
c81c8b68 GKH |
65 | { |
66 | return 0; | |
67 | } | |
68 | ||
a70f81c1 | 69 | static int fdtv_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) |
c81c8b68 | 70 | { |
a70f81c1 | 71 | struct firedtv *fdtv = fe->sec_priv; |
c81c8b68 | 72 | |
a70f81c1 | 73 | fdtv->tone = tone; |
c81c8b68 GKH |
74 | return 0; |
75 | } | |
76 | ||
a70f81c1 | 77 | static int fdtv_set_voltage(struct dvb_frontend *fe, |
15490795 | 78 | fe_sec_voltage_t voltage) |
c81c8b68 | 79 | { |
a70f81c1 | 80 | struct firedtv *fdtv = fe->sec_priv; |
c81c8b68 | 81 | |
a70f81c1 | 82 | fdtv->voltage = voltage; |
c81c8b68 GKH |
83 | return 0; |
84 | } | |
85 | ||
a70f81c1 | 86 | static int fdtv_read_status(struct dvb_frontend *fe, fe_status_t *status) |
c81c8b68 | 87 | { |
a70f81c1 | 88 | struct firedtv *fdtv = fe->sec_priv; |
15490795 | 89 | struct firedtv_tuner_status stat; |
c81c8b68 | 90 | |
15490795 | 91 | if (avc_tuner_status(fdtv, &stat)) |
c81c8b68 GKH |
92 | return -EINVAL; |
93 | ||
15490795 | 94 | if (stat.no_rf) |
c81c8b68 | 95 | *status = 0; |
8ae83cdf SR |
96 | else |
97 | *status = FE_HAS_SIGNAL | FE_HAS_VITERBI | FE_HAS_SYNC | | |
98 | FE_HAS_CARRIER | FE_HAS_LOCK; | |
c81c8b68 GKH |
99 | return 0; |
100 | } | |
101 | ||
a70f81c1 | 102 | static int fdtv_read_ber(struct dvb_frontend *fe, u32 *ber) |
c81c8b68 | 103 | { |
a70f81c1 | 104 | struct firedtv *fdtv = fe->sec_priv; |
15490795 | 105 | struct firedtv_tuner_status stat; |
c81c8b68 | 106 | |
15490795 | 107 | if (avc_tuner_status(fdtv, &stat)) |
c81c8b68 GKH |
108 | return -EINVAL; |
109 | ||
15490795 | 110 | *ber = stat.ber; |
c81c8b68 GKH |
111 | return 0; |
112 | } | |
113 | ||
15490795 | 114 | static int fdtv_read_signal_strength(struct dvb_frontend *fe, u16 *strength) |
c81c8b68 | 115 | { |
a70f81c1 | 116 | struct firedtv *fdtv = fe->sec_priv; |
15490795 | 117 | struct firedtv_tuner_status stat; |
c81c8b68 | 118 | |
15490795 | 119 | if (avc_tuner_status(fdtv, &stat)) |
c81c8b68 GKH |
120 | return -EINVAL; |
121 | ||
15490795 | 122 | *strength = stat.signal_strength << 8; |
c81c8b68 GKH |
123 | return 0; |
124 | } | |
125 | ||
a70f81c1 | 126 | static int fdtv_read_snr(struct dvb_frontend *fe, u16 *snr) |
c81c8b68 | 127 | { |
a70f81c1 | 128 | struct firedtv *fdtv = fe->sec_priv; |
15490795 | 129 | struct firedtv_tuner_status stat; |
df4846c3 | 130 | |
15490795 | 131 | if (avc_tuner_status(fdtv, &stat)) |
df4846c3 HK |
132 | return -EINVAL; |
133 | ||
8ae83cdf | 134 | /* C/N[dB] = -10 * log10(snr / 65535) */ |
15490795 | 135 | *snr = stat.carrier_noise_ratio * 257; |
df4846c3 | 136 | return 0; |
c81c8b68 GKH |
137 | } |
138 | ||
a70f81c1 | 139 | static int fdtv_read_uncorrected_blocks(struct dvb_frontend *fe, u32 *ucblocks) |
c81c8b68 GKH |
140 | { |
141 | return -EOPNOTSUPP; | |
142 | } | |
143 | ||
a70f81c1 | 144 | static int fdtv_set_frontend(struct dvb_frontend *fe, |
15490795 | 145 | struct dvb_frontend_parameters *params) |
c81c8b68 | 146 | { |
a70f81c1 | 147 | struct firedtv *fdtv = fe->sec_priv; |
c81c8b68 | 148 | |
dcff9cfe | 149 | return avc_tuner_dsd(fdtv, params); |
c81c8b68 GKH |
150 | } |
151 | ||
a70f81c1 | 152 | static int fdtv_get_frontend(struct dvb_frontend *fe, |
15490795 | 153 | struct dvb_frontend_parameters *params) |
c81c8b68 GKH |
154 | { |
155 | return -EOPNOTSUPP; | |
156 | } | |
157 | ||
d2fd44a3 TJ |
158 | static int fdtv_get_property(struct dvb_frontend *fe, struct dtv_property *tvp) |
159 | { | |
160 | return 0; | |
161 | } | |
162 | ||
163 | static int fdtv_set_property(struct dvb_frontend *fe, struct dtv_property *tvp) | |
164 | { | |
165 | return 0; | |
166 | } | |
167 | ||
a70f81c1 | 168 | void fdtv_frontend_init(struct firedtv *fdtv) |
8ae83cdf | 169 | { |
a70f81c1 | 170 | struct dvb_frontend_ops *ops = &fdtv->fe.ops; |
8ae83cdf | 171 | struct dvb_frontend_info *fi = &ops->info; |
c81c8b68 | 172 | |
a70f81c1 R |
173 | ops->init = fdtv_dvb_init; |
174 | ops->sleep = fdtv_sleep; | |
c81c8b68 | 175 | |
a70f81c1 R |
176 | ops->set_frontend = fdtv_set_frontend; |
177 | ops->get_frontend = fdtv_get_frontend; | |
c81c8b68 | 178 | |
d2fd44a3 TJ |
179 | ops->get_property = fdtv_get_property; |
180 | ops->set_property = fdtv_set_property; | |
181 | ||
a70f81c1 R |
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; | |
c81c8b68 | 187 | |
a70f81c1 R |
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; | |
c81c8b68 | 192 | |
a70f81c1 R |
193 | switch (fdtv->type) { |
194 | case FIREDTV_DVB_S: | |
8ae83cdf SR |
195 | fi->type = FE_QPSK; |
196 | ||
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; | |
202 | ||
d2fd44a3 | 203 | fi->caps = FE_CAN_INVERSION_AUTO | |
8ae83cdf SR |
204 | FE_CAN_FEC_1_2 | |
205 | FE_CAN_FEC_2_3 | | |
206 | FE_CAN_FEC_3_4 | | |
207 | FE_CAN_FEC_5_6 | | |
208 | FE_CAN_FEC_7_8 | | |
209 | FE_CAN_FEC_AUTO | | |
210 | FE_CAN_QPSK; | |
c81c8b68 | 211 | break; |
8ae83cdf | 212 | |
d2fd44a3 TJ |
213 | case FIREDTV_DVB_S2: |
214 | fi->type = FE_QPSK; | |
215 | ||
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; | |
221 | ||
222 | fi->caps = FE_CAN_INVERSION_AUTO | | |
223 | FE_CAN_FEC_1_2 | | |
224 | FE_CAN_FEC_2_3 | | |
225 | FE_CAN_FEC_3_4 | | |
226 | FE_CAN_FEC_5_6 | | |
227 | FE_CAN_FEC_7_8 | | |
228 | FE_CAN_FEC_AUTO | | |
229 | FE_CAN_QPSK | | |
230 | FE_CAN_2G_MODULATION; | |
231 | break; | |
232 | ||
a70f81c1 | 233 | case FIREDTV_DVB_C: |
8ae83cdf SR |
234 | fi->type = FE_QAM; |
235 | ||
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; | |
241 | ||
242 | fi->caps = FE_CAN_INVERSION_AUTO | | |
243 | FE_CAN_QAM_16 | | |
244 | FE_CAN_QAM_32 | | |
245 | FE_CAN_QAM_64 | | |
246 | FE_CAN_QAM_128 | | |
247 | FE_CAN_QAM_256 | | |
248 | FE_CAN_QAM_AUTO; | |
c81c8b68 | 249 | break; |
8ae83cdf | 250 | |
a70f81c1 | 251 | case FIREDTV_DVB_T: |
8ae83cdf SR |
252 | fi->type = FE_OFDM; |
253 | ||
254 | fi->frequency_min = 49000000; | |
255 | fi->frequency_max = 861000000; | |
256 | fi->frequency_stepsize = 62500; | |
257 | ||
258 | fi->caps = FE_CAN_INVERSION_AUTO | | |
259 | FE_CAN_FEC_2_3 | | |
260 | FE_CAN_TRANSMISSION_MODE_AUTO | | |
261 | FE_CAN_GUARD_INTERVAL_AUTO | | |
262 | FE_CAN_HIERARCHY_AUTO; | |
c81c8b68 | 263 | break; |
8ae83cdf | 264 | |
c81c8b68 | 265 | default: |
15490795 SR |
266 | dev_err(fdtv->device, "no frontend for model type %d\n", |
267 | fdtv->type); | |
c81c8b68 | 268 | } |
a70f81c1 | 269 | strcpy(fi->name, fdtv_model_names[fdtv->type]); |
c81c8b68 | 270 | |
a70f81c1 R |
271 | fdtv->fe.dvb = &fdtv->adapter; |
272 | fdtv->fe.sec_priv = fdtv; | |
c81c8b68 | 273 | } |