Merge branch 'fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/evalenti/linux...
[linux/fpc-iii.git] / drivers / media / dvb-frontends / dvb_dummy_fe.c
blobe5bd8c62ad3a325d68c2aa7f42a16383484ba893
1 /*
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/init.h>
24 #include <linux/string.h>
25 #include <linux/slab.h>
27 #include "dvb_frontend.h"
28 #include "dvb_dummy_fe.h"
31 struct dvb_dummy_fe_state {
32 struct dvb_frontend frontend;
36 static int dvb_dummy_fe_read_status(struct dvb_frontend *fe,
37 enum fe_status *status)
39 *status = FE_HAS_SIGNAL
40 | FE_HAS_CARRIER
41 | FE_HAS_VITERBI
42 | FE_HAS_SYNC
43 | FE_HAS_LOCK;
45 return 0;
48 static int dvb_dummy_fe_read_ber(struct dvb_frontend* fe, u32* ber)
50 *ber = 0;
51 return 0;
54 static int dvb_dummy_fe_read_signal_strength(struct dvb_frontend* fe, u16* strength)
56 *strength = 0;
57 return 0;
60 static int dvb_dummy_fe_read_snr(struct dvb_frontend* fe, u16* snr)
62 *snr = 0;
63 return 0;
66 static int dvb_dummy_fe_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
68 *ucblocks = 0;
69 return 0;
73 * Should only be implemented if it actually reads something from the hardware.
74 * Also, it should check for the locks, in order to avoid report wrong data
75 * to userspace.
77 static int dvb_dummy_fe_get_frontend(struct dvb_frontend *fe,
78 struct dtv_frontend_properties *p)
80 return 0;
83 static int dvb_dummy_fe_set_frontend(struct dvb_frontend *fe)
85 if (fe->ops.tuner_ops.set_params) {
86 fe->ops.tuner_ops.set_params(fe);
87 if (fe->ops.i2c_gate_ctrl)
88 fe->ops.i2c_gate_ctrl(fe, 0);
91 return 0;
94 static int dvb_dummy_fe_sleep(struct dvb_frontend* fe)
96 return 0;
99 static int dvb_dummy_fe_init(struct dvb_frontend* fe)
101 return 0;
104 static int dvb_dummy_fe_set_tone(struct dvb_frontend *fe,
105 enum fe_sec_tone_mode tone)
107 return 0;
110 static int dvb_dummy_fe_set_voltage(struct dvb_frontend *fe,
111 enum fe_sec_voltage voltage)
113 return 0;
116 static void dvb_dummy_fe_release(struct dvb_frontend* fe)
118 struct dvb_dummy_fe_state* state = fe->demodulator_priv;
119 kfree(state);
122 static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops;
124 struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)
126 struct dvb_dummy_fe_state* state = NULL;
128 /* allocate memory for the internal state */
129 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
130 if (!state)
131 return NULL;
133 /* create dvb_frontend */
134 memcpy(&state->frontend.ops, &dvb_dummy_fe_ofdm_ops, sizeof(struct dvb_frontend_ops));
135 state->frontend.demodulator_priv = state;
136 return &state->frontend;
139 static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
141 struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)
143 struct dvb_dummy_fe_state* state = NULL;
145 /* allocate memory for the internal state */
146 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
147 if (!state)
148 return NULL;
150 /* create dvb_frontend */
151 memcpy(&state->frontend.ops, &dvb_dummy_fe_qpsk_ops, sizeof(struct dvb_frontend_ops));
152 state->frontend.demodulator_priv = state;
153 return &state->frontend;
156 static struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
158 struct dvb_frontend *dvb_dummy_fe_qam_attach(void)
160 struct dvb_dummy_fe_state* state = NULL;
162 /* allocate memory for the internal state */
163 state = kzalloc(sizeof(struct dvb_dummy_fe_state), GFP_KERNEL);
164 if (!state)
165 return NULL;
167 /* create dvb_frontend */
168 memcpy(&state->frontend.ops, &dvb_dummy_fe_qam_ops, sizeof(struct dvb_frontend_ops));
169 state->frontend.demodulator_priv = state;
170 return &state->frontend;
173 static struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
174 .delsys = { SYS_DVBT },
175 .info = {
176 .name = "Dummy DVB-T",
177 .frequency_min = 0,
178 .frequency_max = 863250000,
179 .frequency_stepsize = 62500,
180 .caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
181 FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
182 FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
183 FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
184 FE_CAN_TRANSMISSION_MODE_AUTO |
185 FE_CAN_GUARD_INTERVAL_AUTO |
186 FE_CAN_HIERARCHY_AUTO,
189 .release = dvb_dummy_fe_release,
191 .init = dvb_dummy_fe_init,
192 .sleep = dvb_dummy_fe_sleep,
194 .set_frontend = dvb_dummy_fe_set_frontend,
195 .get_frontend = dvb_dummy_fe_get_frontend,
197 .read_status = dvb_dummy_fe_read_status,
198 .read_ber = dvb_dummy_fe_read_ber,
199 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
200 .read_snr = dvb_dummy_fe_read_snr,
201 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
204 static struct dvb_frontend_ops dvb_dummy_fe_qam_ops = {
205 .delsys = { SYS_DVBC_ANNEX_A },
206 .info = {
207 .name = "Dummy DVB-C",
208 .frequency_stepsize = 62500,
209 .frequency_min = 51000000,
210 .frequency_max = 858000000,
211 .symbol_rate_min = (57840000/2)/64, /* SACLK/64 == (XIN/2)/64 */
212 .symbol_rate_max = (57840000/2)/4, /* SACLK/4 */
213 .caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
214 FE_CAN_QAM_128 | FE_CAN_QAM_256 |
215 FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
218 .release = dvb_dummy_fe_release,
220 .init = dvb_dummy_fe_init,
221 .sleep = dvb_dummy_fe_sleep,
223 .set_frontend = dvb_dummy_fe_set_frontend,
224 .get_frontend = dvb_dummy_fe_get_frontend,
226 .read_status = dvb_dummy_fe_read_status,
227 .read_ber = dvb_dummy_fe_read_ber,
228 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
229 .read_snr = dvb_dummy_fe_read_snr,
230 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
233 static struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops = {
234 .delsys = { SYS_DVBS },
235 .info = {
236 .name = "Dummy DVB-S",
237 .frequency_min = 950000,
238 .frequency_max = 2150000,
239 .frequency_stepsize = 250, /* kHz for QPSK frontends */
240 .frequency_tolerance = 29500,
241 .symbol_rate_min = 1000000,
242 .symbol_rate_max = 45000000,
243 .caps = FE_CAN_INVERSION_AUTO |
244 FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
245 FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
246 FE_CAN_QPSK
249 .release = dvb_dummy_fe_release,
251 .init = dvb_dummy_fe_init,
252 .sleep = dvb_dummy_fe_sleep,
254 .set_frontend = dvb_dummy_fe_set_frontend,
255 .get_frontend = dvb_dummy_fe_get_frontend,
257 .read_status = dvb_dummy_fe_read_status,
258 .read_ber = dvb_dummy_fe_read_ber,
259 .read_signal_strength = dvb_dummy_fe_read_signal_strength,
260 .read_snr = dvb_dummy_fe_read_snr,
261 .read_ucblocks = dvb_dummy_fe_read_ucblocks,
263 .set_voltage = dvb_dummy_fe_set_voltage,
264 .set_tone = dvb_dummy_fe_set_tone,
267 MODULE_DESCRIPTION("DVB DUMMY Frontend");
268 MODULE_AUTHOR("Emard");
269 MODULE_LICENSE("GPL");
271 EXPORT_SYMBOL(dvb_dummy_fe_ofdm_attach);
272 EXPORT_SYMBOL(dvb_dummy_fe_qam_attach);
273 EXPORT_SYMBOL(dvb_dummy_fe_qpsk_attach);