1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
|
/*
* Driver for Dummy Frontend
*
* Written by Emard <emard@softhome.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
*/
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h>
#include "dvb_frontend.h"
#define FRONTEND_NAME "dvbfe_dummy"
static int frontend_type;
module_param(frontend_type, int, 0444);
MODULE_PARM_DESC(frontend_type, "0 == DVB-S, 1 == DVB-C, 2 == DVB-T");
/* depending on module parameter sct deliver different infos
*/
static struct dvb_frontend_info dvb_s_dummyfe_info = {
.name = "DVB-S dummy frontend",
.type = FE_QPSK,
.frequency_min = 950000,
.frequency_max = 2150000,
.frequency_stepsize = 250, /* kHz for QPSK frontends */
.frequency_tolerance = 29500,
.symbol_rate_min = 1000000,
.symbol_rate_max = 45000000,
/* .symbol_rate_tolerance = ???,*/
.notifier_delay = 50, /* 1/20 s */
.caps = FE_CAN_INVERSION_AUTO |
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
FE_CAN_QPSK
};
static struct dvb_frontend_info dvb_c_dummyfe_info = {
.name = "DVB-C dummy frontend",
.type = FE_QAM,
.frequency_stepsize = 62500,
.frequency_min = 51000000,
.frequency_max = 858000000,
.symbol_rate_min = (57840000/2)/64, /* SACLK/64 == (XIN/2)/64 */
.symbol_rate_max = (57840000/2)/4, /* SACLK/4 */
#if 0
.frequency_tolerance = ???,
.symbol_rate_tolerance = ???, /* ppm */ /* == 8% (spec p. 5) */
.notifier_delay = ?,
#endif
.caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
FE_CAN_QAM_128 | FE_CAN_QAM_256 |
FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
};
static struct dvb_frontend_info dvb_t_dummyfe_info = {
.name = "DVB-T dummy frontend",
.type = FE_OFDM,
.frequency_min = 0,
.frequency_max = 863250000,
.frequency_stepsize = 62500,
/*.frequency_tolerance = */ /* FIXME: 12% of SR */
.symbol_rate_min = 0, /* FIXME */
.symbol_rate_max = 9360000, /* FIXME */
.symbol_rate_tolerance = 4000,
.notifier_delay = 0,
.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
FE_CAN_TRANSMISSION_MODE_AUTO |
FE_CAN_GUARD_INTERVAL_AUTO |
FE_CAN_HIERARCHY_AUTO,
};
struct dvb_frontend_info *frontend_info(void)
{
switch(frontend_type) {
case 2:
return &dvb_t_dummyfe_info;
case 1:
return &dvb_c_dummyfe_info;
case 0:
default:
return &dvb_s_dummyfe_info;
}
}
static int dvbdummyfe_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
switch (cmd) {
case FE_GET_INFO:
memcpy (arg, frontend_info(),
sizeof(struct dvb_frontend_info));
break;
case FE_READ_STATUS:
{
fe_status_t *status = arg;
*status = FE_HAS_SIGNAL
| FE_HAS_CARRIER
| FE_HAS_VITERBI
| FE_HAS_SYNC
| FE_HAS_LOCK;
break;
}
case FE_READ_BER:
{
u32 *ber = (u32 *) arg;
*ber = 0;
break;
}
case FE_READ_SIGNAL_STRENGTH:
{
u8 signal = 0xff;
*((u16*) arg) = (signal << 8) | signal;
break;
}
case FE_READ_SNR:
{
u8 snr = 0xf0;
*(u16*) arg = (snr << 8) | snr;
break;
}
case FE_READ_UNCORRECTED_BLOCKS:
*(u32*) arg = 0;
break;
case FE_SET_FRONTEND:
break;
case FE_GET_FRONTEND:
break;
case FE_SLEEP:
return 0;
case FE_INIT:
return 0;
case FE_SET_TONE:
return -EOPNOTSUPP;
case FE_SET_VOLTAGE:
return 0;
default:
return -EOPNOTSUPP;
}
return 0;
}
static struct i2c_client client_template;
static int dvbdummyfe_attach_adapter(struct i2c_adapter *adapter)
{
struct dvb_adapter *dvb;
struct i2c_client *client;
int ret;
if ((client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)) == NULL)
return -ENOMEM;
memcpy(client, &client_template, sizeof(struct i2c_client));
client->adapter = adapter;
if ((ret = i2c_attach_client(client))) {
kfree(client);
return ret;
}
dvb = i2c_get_clientdata(client);
BUG_ON(!dvb);
if ((ret = dvb_register_frontend(dvbdummyfe_ioctl, dvb, NULL,
frontend_info(), THIS_MODULE))) {
kfree(client);
return ret;
}
return 0;
}
static int dvbdummyfe_detach_client(struct i2c_client *client)
{
struct dvb_adapter *dvb = i2c_get_clientdata(client);
dvb_unregister_frontend(dvbdummyfe_ioctl, dvb);
i2c_detach_client(client);
kfree(client);
return 0;
}
static int dvbdummyfe_command(struct i2c_client *client,
unsigned int cmd, void *arg)
{
switch(cmd) {
case FE_REGISTER:
i2c_set_clientdata(client, arg);
break;
case FE_UNREGISTER:
break;
default:
return -EOPNOTSUPP;
}
return 0;
}
static struct i2c_driver driver = {
.owner = THIS_MODULE,
.name = FRONTEND_NAME,
.id = I2C_DRIVERID_DVBFE_DUMMY,
.flags = I2C_DF_NOTIFY,
.attach_adapter = dvbdummyfe_attach_adapter,
.detach_client = dvbdummyfe_detach_client,
.command = dvbdummyfe_command,
};
static struct i2c_client client_template = {
.name = FRONTEND_NAME,
.flags = I2C_CLIENT_ALLOW_USE,
.driver = &driver,
};
static int __init init_dvbdummyfe (void)
{
return i2c_add_driver(&driver);
}
static void __exit exit_dvbdummyfe (void)
{
if (i2c_del_driver(&driver))
printk(KERN_ERR "dummyfe: driver deregistration failed.\n");
}
module_init(init_dvbdummyfe);
module_exit(exit_dvbdummyfe);
MODULE_DESCRIPTION("DVB DUMMY Frontend");
MODULE_AUTHOR("Emard");
MODULE_LICENSE("GPL");
|