blob: 645946a992d94b1dda65bf33e14561238ee6329f [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Driver for Dummy Frontend
3 *
4 * Written by Emard <emard@softhome.net>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 *
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.=
20 */
21
22#include <linux/module.h>
23#include <linux/moduleparam.h>
24#include <linux/init.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -080025#include <linux/string.h>
26#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
28#include "dvb_frontend.h"
29#include "dvb_dummy_fe.h"
30
31
32struct dvb_dummy_fe_state {
33 struct dvb_frontend_ops ops;
34 struct dvb_frontend frontend;
35};
36
37
38static int dvb_dummy_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
39{
40 *status = FE_HAS_SIGNAL
41 | FE_HAS_CARRIER
42 | FE_HAS_VITERBI
43 | FE_HAS_SYNC
44 | FE_HAS_LOCK;
45
46 return 0;
47}
48
49static int dvb_dummy_fe_read_ber(struct dvb_frontend* fe, u32* ber)
50{
51 *ber = 0;
52 return 0;
53}
54
55static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
56{
57 *strength = 0;
58 return 0;
59}
60
61static int dvb_dummy_fe_read_snr(struct dvb_frontend* fe, u16* snr)
62{
63 *snr = 0;
64 return 0;
65}
66
67static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
68{
69 *ucblocks = 0;
70 return 0;
71}
72
73static int dvb_dummy_fe_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
74{
75 return 0;
76}
77
78static int dvb_dummy_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
79{
80 return 0;
81}
82
83static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
84{
85 return 0;
86}
87
88static int dvb_dummy_fe_init(struct dvb_frontend* fe)
89{
90 return 0;
91}
92
93static int dvb_dummy_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
94{
95 return 0;
96}
97
98static int dvb_dummy_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
99{
100 return 0;
101}
102
103static void dvb_dummy_fe_release(struct dvb_frontend* fe)
104{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700105 struct dvb_dummy_fe_state* state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700106 kfree(state);
107}
108
109static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
110
111struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
112{
113 struct dvb_dummy_fe_state* state = NULL;
114
115 /* allocate memory for the internal state */
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700116 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700117 if (state == NULL) goto error;
118
119 /* setup the state */
120 memcpy(&state->ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
121
122 /* create dvb_frontend */
123 state->frontend.ops = &state->ops;
124 state->frontend.demodulator_priv = state;
125 return &state->frontend;
126
127error:
128 kfree(state);
129 return NULL;
130}
131
132static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
133
134struct dvb_frontend* dvb_dummy_fe_qpsk_attach()
135{
136 struct dvb_dummy_fe_state* state = NULL;
137
138 /* allocate memory for the internal state */
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700139 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700140 if (state == NULL) goto error;
141
142 /* setup the state */
143 memcpy(&state->ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
144
145 /* create dvb_frontend */
146 state->frontend.ops = &state->ops;
147 state->frontend.demodulator_priv = state;
148 return &state->frontend;
149
150error:
Jesper Juhl2ea75332005-11-07 01:01:31 -0800151 kfree(state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152 return NULL;
153}
154
155static struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
156
157struct dvb_frontend* dvb_dummy_fe_qam_attach()
158{
159 struct dvb_dummy_fe_state* state = NULL;
160
161 /* allocate memory for the internal state */
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700162 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 if (state == NULL) goto error;
164
165 /* setup the state */
166 memcpy(&state->ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
167
168 /* create dvb_frontend */
169 state->frontend.ops = &state->ops;
170 state->frontend.demodulator_priv = state;
171 return &state->frontend;
172
173error:
Jesper Juhl2ea75332005-11-07 01:01:31 -0800174 kfree(state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 return NULL;
176}
177
178static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
179
180 .info = {
181 .name = "Dummy DVB-T",
182 .type = FE_OFDM,
183 .frequency_min = 0,
184 .frequency_max = 863250000,
185 .frequency_stepsize = 62500,
186 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
187 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
188 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
189 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
190 FE_CAN_TRANSMISSION_MODE_AUTO |
191 FE_CAN_GUARD_INTERVAL_AUTO |
192 FE_CAN_HIERARCHY_AUTO,
193 },
194
195 .release = dvb_dummy_fe_release,
196
197 .init = dvb_dummy_fe_init,
198 .sleep = dvb_dummy_fe_sleep,
199
200 .set_frontend = dvb_dummy_fe_set_frontend,
201 .get_frontend = dvb_dummy_fe_get_frontend,
202
203 .read_status = dvb_dummy_fe_read_status,
204 .read_ber = dvb_dummy_fe_read_ber,
205 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
206 .read_snr = dvb_dummy_fe_read_snr,
207 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
208};
209
210static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
211
212 .info = {
213 .name = "Dummy DVB-C",
214 .type = FE_QAM,
215 .frequency_stepsize = 62500,
216 .frequency_min = 51000000,
217 .frequency_max = 858000000,
218 .symbol_rate_min = (57840000/2)/64, /* SACLK/64 == (XIN/2)/64 */
219 .symbol_rate_max = (57840000/2)/4, /* SACLK/4 */
220 .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
221 FE_CAN_QAM_128 | FE_CAN_QAM_256 |
222 FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
223 },
224
225 .release = dvb_dummy_fe_release,
226
227 .init = dvb_dummy_fe_init,
228 .sleep = dvb_dummy_fe_sleep,
229
230 .set_frontend = dvb_dummy_fe_set_frontend,
231 .get_frontend = dvb_dummy_fe_get_frontend,
232
233 .read_status = dvb_dummy_fe_read_status,
234 .read_ber = dvb_dummy_fe_read_ber,
235 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
236 .read_snr = dvb_dummy_fe_read_snr,
237 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
238};
239
240static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
241
242 .info = {
243 .name = "Dummy DVB-S",
244 .type = FE_QPSK,
245 .frequency_min = 950000,
246 .frequency_max = 2150000,
247 .frequency_stepsize = 250, /* kHz for QPSK frontends */
248 .frequency_tolerance = 29500,
249 .symbol_rate_min = 1000000,
250 .symbol_rate_max = 45000000,
251 .caps = FE_CAN_INVERSION_AUTO |
252 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
253 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
254 FE_CAN_QPSK
255 },
256
257 .release = dvb_dummy_fe_release,
258
259 .init = dvb_dummy_fe_init,
260 .sleep = dvb_dummy_fe_sleep,
261
262 .set_frontend = dvb_dummy_fe_set_frontend,
263 .get_frontend = dvb_dummy_fe_get_frontend,
264
265 .read_status = dvb_dummy_fe_read_status,
266 .read_ber = dvb_dummy_fe_read_ber,
267 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
268 .read_snr = dvb_dummy_fe_read_snr,
269 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
270
271 .set_voltage = dvb_dummy_fe_set_voltage,
272 .set_tone = dvb_dummy_fe_set_tone,
273};
274
275MODULE_DESCRIPTION("DVB DUMMY Frontend");
276MODULE_AUTHOR("Emard");
277MODULE_LICENSE("GPL");
278
279EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach);
280EXPORT_SYMBOL(dvb_dummy_fe_qam_attach);
281EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach);