2 * Driver for Dummy Frontend
4 * Written by Emard <emard@softhome.net>
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.
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
15 * GNU General Public License for more details.
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.=
22 #include <linux/module.h>
23 #include <linux/moduleparam.h>
24 #include <linux/init.h>
25 #include <linux/string.h>
26 #include <linux/slab.h>
28 #include "dvb_frontend.h"
29 #include "dvb_dummy_fe.h"
32 struct dvb_dummy_fe_state {
33 struct dvb_frontend frontend;
37 static int dvb_dummy_fe_read_status(struct dvb_frontend* fe, fe_status_t* status)
39 *status = FE_HAS_SIGNAL
48 static int dvb_dummy_fe_read_ber(struct dvb_frontend* fe, u32* ber)
54 static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
60 static int dvb_dummy_fe_read_snr(struct dvb_frontend* fe, u16* snr)
66 static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
72 static int dvb_dummy_fe_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
77 static int dvb_dummy_fe_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p)
79 if (fe->ops->tuner_ops->set_params) {
80 fe->ops->tuner_ops->set_params(fe, p);
81 if (fe->ops->i2c_gate_ctrl) fe->ops->i2c_gate_ctrl(fe, 0);
87 static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
92 static int dvb_dummy_fe_init(struct dvb_frontend* fe)
97 static int dvb_dummy_fe_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
102 static int dvb_dummy_fe_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
107 static void dvb_dummy_fe_release(struct dvb_frontend* fe)
109 struct dvb_dummy_fe_state* state = fe->demodulator_priv;
113 static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
115 struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
117 struct dvb_dummy_fe_state* state = NULL;
119 /* allocate memory for the internal state */
120 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
121 if (state == NULL) goto error;
123 /* create dvb_frontend */
124 memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
125 state->frontend.demodulator_priv = state;
126 return &state->frontend;
133 static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
135 struct dvb_frontend* dvb_dummy_fe_qpsk_attach()
137 struct dvb_dummy_fe_state* state = NULL;
139 /* allocate memory for the internal state */
140 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
141 if (state == NULL) goto error;
143 /* create dvb_frontend */
144 memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
145 state->frontend.demodulator_priv = state;
146 return &state->frontend;
153 static struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
155 struct dvb_frontend* dvb_dummy_fe_qam_attach()
157 struct dvb_dummy_fe_state* state = NULL;
159 /* allocate memory for the internal state */
160 state = kmalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
161 if (state == NULL) goto error;
163 /* create dvb_frontend */
164 memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
165 state->frontend.demodulator_priv = state;
166 return &state->frontend;
173 static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
176 .name = "Dummy DVB-T",
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,
190 .release = dvb_dummy_fe_release,
192 .init = dvb_dummy_fe_init,
193 .sleep = dvb_dummy_fe_sleep,
195 .set_frontend = dvb_dummy_fe_set_frontend,
196 .get_frontend = dvb_dummy_fe_get_frontend,
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,
205 static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
208 .name = "Dummy DVB-C",
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
220 .release = dvb_dummy_fe_release,
222 .init = dvb_dummy_fe_init,
223 .sleep = dvb_dummy_fe_sleep,
225 .set_frontend = dvb_dummy_fe_set_frontend,
226 .get_frontend = dvb_dummy_fe_get_frontend,
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,
235 static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
238 .name = "Dummy DVB-S",
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 |
252 .release = dvb_dummy_fe_release,
254 .init = dvb_dummy_fe_init,
255 .sleep = dvb_dummy_fe_sleep,
257 .set_frontend = dvb_dummy_fe_set_frontend,
258 .get_frontend = dvb_dummy_fe_get_frontend,
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,
266 .set_voltage = dvb_dummy_fe_set_voltage,
267 .set_tone = dvb_dummy_fe_set_tone,
270 MODULE_DESCRIPTION("DVB DUMMY Frontend");
271 MODULE_AUTHOR("Emard");
272 MODULE_LICENSE("GPL");
274 EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach);
275 EXPORT_SYMBOL(dvb_dummy_fe_qam_attach);
276 EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach);