aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/firesat/firesat_fe.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/firesat/firesat_fe.c')
-rw-r--r--drivers/media/dvb/firesat/firesat_fe.c263
1 files changed, 263 insertions, 0 deletions
diff --git a/drivers/media/dvb/firesat/firesat_fe.c b/drivers/media/dvb/firesat/firesat_fe.c
new file mode 100644
index 000000000000..f7abd38f0014
--- /dev/null
+++ b/drivers/media/dvb/firesat/firesat_fe.c
@@ -0,0 +1,263 @@
1#include <linux/init.h>
2#include <linux/slab.h>
3#include <linux/wait.h>
4#include <linux/module.h>
5#include <linux/delay.h>
6#include <linux/time.h>
7#include <linux/errno.h>
8#include <linux/interrupt.h>
9#include <linux/semaphore.h>
10#include <ieee1394_hotplug.h>
11#include <nodemgr.h>
12#include <highlevel.h>
13#include <ohci1394.h>
14#include <hosts.h>
15#include <dvbdev.h>
16
17#include "firesat.h"
18#include "avc_api.h"
19#include "cmp.h"
20#include "firesat-rc.h"
21#include "firesat-ci.h"
22
23static int firesat_dvb_init(struct dvb_frontend *fe)
24{
25 struct firesat *firesat = fe->sec_priv;
26 printk("fdi: 1\n");
27 firesat->isochannel = firesat->adapter->num; //<< 1 | (firesat->subunit & 0x1); // ### ask IRM
28 printk("fdi: 2\n");
29 try_CMPEstablishPPconnection(firesat, firesat->subunit, firesat->isochannel);
30 printk("fdi: 3\n");
31//FIXME hpsb_listen_channel(&firesat_highlevel, firesat->host, firesat->isochannel);
32 printk("fdi: 4\n");
33 return 0;
34}
35
36static int firesat_sleep(struct dvb_frontend *fe)
37{
38 struct firesat *firesat = fe->sec_priv;
39
40//FIXME hpsb_unlisten_channel(&firesat_highlevel, firesat->host, firesat->isochannel);
41 try_CMPBreakPPconnection(firesat, firesat->subunit, firesat->isochannel);
42 firesat->isochannel = -1;
43 return 0;
44}
45
46static int firesat_diseqc_send_master_cmd(struct dvb_frontend *fe,
47 struct dvb_diseqc_master_cmd *cmd)
48{
49 struct firesat *firesat = fe->sec_priv;
50
51 return AVCLNBControl(firesat, LNBCONTROL_DONTCARE, LNBCONTROL_DONTCARE,
52 LNBCONTROL_DONTCARE, 1, cmd);
53}
54
55static int firesat_diseqc_send_burst(struct dvb_frontend *fe,
56 fe_sec_mini_cmd_t minicmd)
57{
58 return 0;
59}
60
61static int firesat_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
62{
63 struct firesat *firesat = fe->sec_priv;
64
65 firesat->tone = tone;
66 return 0;
67}
68
69static int firesat_set_voltage(struct dvb_frontend *fe,
70 fe_sec_voltage_t voltage)
71{
72 struct firesat *firesat = fe->sec_priv;
73
74 firesat->voltage = voltage;
75 return 0;
76}
77
78static int firesat_read_status (struct dvb_frontend *fe, fe_status_t *status)
79{
80 struct firesat *firesat = fe->sec_priv;
81 ANTENNA_INPUT_INFO info;
82
83 if (AVCTunerStatus(firesat, &info))
84 return -EINVAL;
85
86 if (info.NoRF)
87 *status = 0;
88 else
89 *status = *status = FE_HAS_SIGNAL |
90 FE_HAS_VITERBI |
91 FE_HAS_SYNC |
92 FE_HAS_CARRIER |
93 FE_HAS_LOCK;
94
95 return 0;
96}
97
98static int firesat_read_ber (struct dvb_frontend *fe, u32 *ber)
99{
100 struct firesat *firesat = fe->sec_priv;
101 ANTENNA_INPUT_INFO info;
102
103 if (AVCTunerStatus(firesat, &info))
104 return -EINVAL;
105
106 *ber = ((info.BER[0] << 24) & 0xff) |
107 ((info.BER[1] << 16) & 0xff) |
108 ((info.BER[2] << 8) & 0xff) |
109 (info.BER[3] & 0xff);
110
111 return 0;
112}
113
114static int firesat_read_signal_strength (struct dvb_frontend *fe, u16 *strength)
115{
116 struct firesat *firesat = fe->sec_priv;
117 ANTENNA_INPUT_INFO info;
118 u16 *signal = strength;
119
120 if (AVCTunerStatus(firesat, &info))
121 return -EINVAL;
122
123 *signal = info.SignalStrength;
124
125 return 0;
126}
127
128static int firesat_read_snr(struct dvb_frontend *fe, u16 *snr)
129{
130 return -EOPNOTSUPP;
131}
132
133static int firesat_read_uncorrected_blocks(struct dvb_frontend *fe, u32 *ucblocks)
134{
135 return -EOPNOTSUPP;
136}
137
138static int firesat_set_frontend(struct dvb_frontend *fe,
139 struct dvb_frontend_parameters *params)
140{
141 struct firesat *firesat = fe->sec_priv;
142
143 if (AVCTuner_DSD(firesat, params, NULL) != ACCEPTED)
144 return -EINVAL;
145 else
146 return 0; //not sure of this...
147}
148
149static int firesat_get_frontend(struct dvb_frontend *fe,
150 struct dvb_frontend_parameters *params)
151{
152 return -EOPNOTSUPP;
153}
154
155static struct dvb_frontend_info firesat_S_frontend_info;
156static struct dvb_frontend_info firesat_C_frontend_info;
157static struct dvb_frontend_info firesat_T_frontend_info;
158
159static struct dvb_frontend_ops firesat_ops = {
160
161 .init = firesat_dvb_init,
162 .sleep = firesat_sleep,
163
164 .set_frontend = firesat_set_frontend,
165 .get_frontend = firesat_get_frontend,
166
167 .read_status = firesat_read_status,
168 .read_ber = firesat_read_ber,
169 .read_signal_strength = firesat_read_signal_strength,
170 .read_snr = firesat_read_snr,
171 .read_ucblocks = firesat_read_uncorrected_blocks,
172
173 .diseqc_send_master_cmd = firesat_diseqc_send_master_cmd,
174 .diseqc_send_burst = firesat_diseqc_send_burst,
175 .set_tone = firesat_set_tone,
176 .set_voltage = firesat_set_voltage,
177};
178
179int firesat_frontend_attach(struct firesat *firesat, struct dvb_frontend *fe)
180{
181 switch (firesat->type) {
182 case FireSAT_DVB_S:
183 firesat->model_name = "FireSAT DVB-S";
184 firesat->frontend_info = &firesat_S_frontend_info;
185 break;
186 case FireSAT_DVB_C:
187 firesat->model_name = "FireSAT DVB-C";
188 firesat->frontend_info = &firesat_C_frontend_info;
189 break;
190 case FireSAT_DVB_T:
191 firesat->model_name = "FireSAT DVB-T";
192 firesat->frontend_info = &firesat_T_frontend_info;
193 break;
194 default:
195// printk("%s: unknown model type 0x%x on subunit %d!\n",
196// __func__, firesat->type,subunit);
197 printk("%s: unknown model type 0x%x !\n",
198 __func__, firesat->type);
199 firesat->model_name = "Unknown";
200 firesat->frontend_info = NULL;
201 }
202 fe->ops = firesat_ops;
203 fe->dvb = firesat->adapter;
204
205 return 0;
206}
207
208static struct dvb_frontend_info firesat_S_frontend_info = {
209
210 .name = "FireSAT DVB-S Frontend",
211 .type = FE_QPSK,
212
213 .frequency_min = 950000,
214 .frequency_max = 2150000,
215 .frequency_stepsize = 125,
216 .symbol_rate_min = 1000000,
217 .symbol_rate_max = 40000000,
218
219 .caps = FE_CAN_INVERSION_AUTO |
220 FE_CAN_FEC_1_2 |
221 FE_CAN_FEC_2_3 |
222 FE_CAN_FEC_3_4 |
223 FE_CAN_FEC_5_6 |
224 FE_CAN_FEC_7_8 |
225 FE_CAN_FEC_AUTO |
226 FE_CAN_QPSK,
227};
228
229static struct dvb_frontend_info firesat_C_frontend_info = {
230
231 .name = "FireSAT DVB-C Frontend",
232 .type = FE_QAM,
233
234 .frequency_min = 47000000,
235 .frequency_max = 866000000,
236 .frequency_stepsize = 62500,
237 .symbol_rate_min = 870000,
238 .symbol_rate_max = 6900000,
239
240 .caps = FE_CAN_INVERSION_AUTO |
241 FE_CAN_QAM_16 |
242 FE_CAN_QAM_32 |
243 FE_CAN_QAM_64 |
244 FE_CAN_QAM_128 |
245 FE_CAN_QAM_256 |
246 FE_CAN_QAM_AUTO,
247};
248
249static struct dvb_frontend_info firesat_T_frontend_info = {
250
251 .name = "FireSAT DVB-T Frontend",
252 .type = FE_OFDM,
253
254 .frequency_min = 49000000,
255 .frequency_max = 861000000,
256 .frequency_stepsize = 62500,
257
258 .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,
263};