blob: db8a937cc63008dbabe4a1225810f03e80916d31 [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>
Linus Torvalds1da177e2005-04-16 15:20:36 -070023#include <linux/init.h>
Tim Schmielau4e57b682005-10-30 15:03:48 -080024#include <linux/string.h>
25#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070026
27#include "dvb_frontend.h"
28#include "dvb_dummy_fe.h"
29
30
31struct dvb_dummy_fe_state {
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 struct dvb_frontend frontend;
33};
34
35
36static int dvb_dummy_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
37{
38 *status = FE_HAS_SIGNAL
39 | FE_HAS_CARRIER
40 | FE_HAS_VITERBI
41 | FE_HAS_SYNC
42 | FE_HAS_LOCK;
43
44 return 0;
45}
46
47static int dvb_dummy_fe_read_ber(struct dvb_frontend* fe, u32* ber)
48{
49 *ber = 0;
50 return 0;
51}
52
53static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
54{
55 *strength = 0;
56 return 0;
57}
58
59static int dvb_dummy_fe_read_snr(struct dvb_frontend* fe, u16* snr)
60{
61 *snr = 0;
62 return 0;
63}
64
65static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
66{
67 *ucblocks = 0;
68 return 0;
69}
70
71static int dvb_dummy_fe_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
72{
73 return 0;
74}
75
76static int dvb_dummy_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
77{
Patrick Boettcherbccd7002008-08-30 12:15:54 -030078 if (fe->ops.tuner_ops.set_params) {
79 fe->ops.tuner_ops.set_params(fe, p);
80 if (fe->ops.i2c_gate_ctrl)
81 fe->ops.i2c_gate_ctrl(fe, 0);
Andrew de Quincey089e9802006-04-18 17:47:10 -030082 }
83
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 return 0;
85}
86
87static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
88{
89 return 0;
90}
91
92static int dvb_dummy_fe_init(struct dvb_frontend* fe)
93{
94 return 0;
95}
96
97static int dvb_dummy_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
98{
99 return 0;
100}
101
102static int dvb_dummy_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
103{
104 return 0;
105}
106
107static void dvb_dummy_fe_release(struct dvb_frontend* fe)
108{
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700109 struct dvb_dummy_fe_state* state = fe->demodulator_priv;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 kfree(state);
111}
112
113static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
114
115struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
116{
117 struct dvb_dummy_fe_state* state = NULL;
118
119 /* allocate memory for the internal state */
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700120 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 if (state == NULL) goto error;
122
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 /* create dvb_frontend */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300124 memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 state->frontend.demodulator_priv = state;
126 return &state->frontend;
127
128error:
129 kfree(state);
130 return NULL;
131}
132
133static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
134
Hans Verkuild45b9b82008-09-04 03:33:43 -0300135struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700136{
137 struct dvb_dummy_fe_state* state = NULL;
138
139 /* allocate memory for the internal state */
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700140 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 if (state == NULL) goto error;
142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 /* create dvb_frontend */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300144 memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700145 state->frontend.demodulator_priv = state;
146 return &state->frontend;
147
148error:
Jesper Juhl2ea75332005-11-07 01:01:31 -0800149 kfree(state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150 return NULL;
151}
152
153static struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
154
Hans Verkuild45b9b82008-09-04 03:33:43 -0300155struct dvb_frontend *dvb_dummy_fe_qam_attach(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700156{
157 struct dvb_dummy_fe_state* state = NULL;
158
159 /* allocate memory for the internal state */
Johannes Stezenbachb8742702005-05-16 21:54:31 -0700160 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 if (state == NULL) goto error;
162
Linus Torvalds1da177e2005-04-16 15:20:36 -0700163 /* create dvb_frontend */
Patrick Boettcherdea74862006-05-14 05:01:31 -0300164 memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700165 state->frontend.demodulator_priv = state;
166 return &state->frontend;
167
168error:
Jesper Juhl2ea75332005-11-07 01:01:31 -0800169 kfree(state);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170 return NULL;
171}
172
173static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
174
175 .info = {
176 .name = "Dummy DVB-T",
177 .type = FE_OFDM,
178 .frequency_min = 0,
179 .frequency_max = 863250000,
180 .frequency_stepsize = 62500,
181 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
182 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
183 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
184 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
185 FE_CAN_TRANSMISSION_MODE_AUTO |
186 FE_CAN_GUARD_INTERVAL_AUTO |
187 FE_CAN_HIERARCHY_AUTO,
188 },
189
190 .release = dvb_dummy_fe_release,
191
192 .init = dvb_dummy_fe_init,
193 .sleep = dvb_dummy_fe_sleep,
194
195 .set_frontend = dvb_dummy_fe_set_frontend,
196 .get_frontend = dvb_dummy_fe_get_frontend,
197
198 .read_status = dvb_dummy_fe_read_status,
199 .read_ber = dvb_dummy_fe_read_ber,
200 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
201 .read_snr = dvb_dummy_fe_read_snr,
202 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
203};
204
205static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
206
207 .info = {
208 .name = "Dummy DVB-C",
209 .type = FE_QAM,
210 .frequency_stepsize = 62500,
211 .frequency_min = 51000000,
212 .frequency_max = 858000000,
213 .symbol_rate_min = (57840000/2)/64, /* SACLK/64 == (XIN/2)/64 */
214 .symbol_rate_max = (57840000/2)/4, /* SACLK/4 */
215 .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
216 FE_CAN_QAM_128 | FE_CAN_QAM_256 |
217 FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
218 },
219
220 .release = dvb_dummy_fe_release,
221
222 .init = dvb_dummy_fe_init,
223 .sleep = dvb_dummy_fe_sleep,
224
225 .set_frontend = dvb_dummy_fe_set_frontend,
226 .get_frontend = dvb_dummy_fe_get_frontend,
227
228 .read_status = dvb_dummy_fe_read_status,
229 .read_ber = dvb_dummy_fe_read_ber,
230 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
231 .read_snr = dvb_dummy_fe_read_snr,
232 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
233};
234
235static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
236
237 .info = {
238 .name = "Dummy DVB-S",
239 .type = FE_QPSK,
240 .frequency_min = 950000,
241 .frequency_max = 2150000,
242 .frequency_stepsize = 250, /* kHz for QPSK frontends */
243 .frequency_tolerance = 29500,
244 .symbol_rate_min = 1000000,
245 .symbol_rate_max = 45000000,
246 .caps = FE_CAN_INVERSION_AUTO |
247 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
248 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
249 FE_CAN_QPSK
250 },
251
252 .release = dvb_dummy_fe_release,
253
254 .init = dvb_dummy_fe_init,
255 .sleep = dvb_dummy_fe_sleep,
256
257 .set_frontend = dvb_dummy_fe_set_frontend,
258 .get_frontend = dvb_dummy_fe_get_frontend,
259
260 .read_status = dvb_dummy_fe_read_status,
261 .read_ber = dvb_dummy_fe_read_ber,
262 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
263 .read_snr = dvb_dummy_fe_read_snr,
264 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
265
266 .set_voltage = dvb_dummy_fe_set_voltage,
267 .set_tone = dvb_dummy_fe_set_tone,
268};
269
270MODULE_DESCRIPTION("DVB DUMMY Frontend");
271MODULE_AUTHOR("Emard");
272MODULE_LICENSE("GPL");
273
274EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach);
275EXPORT_SYMBOL(dvb_dummy_fe_qam_attach);
276EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach);